diff --git a/packages/order-watcher/CHANGELOG.json b/packages/order-watcher/CHANGELOG.json index da94a99cb9..89d6b905fe 100644 --- a/packages/order-watcher/CHANGELOG.json +++ b/packages/order-watcher/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "version": "4.0.7", + "changes": [ + { + "note": "Fix race-condition bug due to async callback modifying shared state", + "pr": 1789 + } + ] + }, { "version": "4.0.6", "changes": [ diff --git a/packages/order-watcher/src/order_watcher/order_watcher.ts b/packages/order-watcher/src/order_watcher/order_watcher.ts index 7550f5c3ab..78c619859f 100644 --- a/packages/order-watcher/src/order_watcher/order_watcher.ts +++ b/packages/order-watcher/src/order_watcher/order_watcher.ts @@ -493,6 +493,9 @@ export class OrderWatcher { private async _emitRevalidateOrdersAsync(orderHashes: string[], transactionHash?: string): Promise { for (const orderHash of orderHashes) { const signedOrder = this._orderByOrderHash[orderHash]; + if (signedOrder === undefined) { + continue; + } // Most of these calls will never reach the network because the data is fetched from stores // and only updated when cache is invalidated const orderState = await this._orderStateUtils.getOpenOrderStateAsync(signedOrder, transactionHash);