Merge pull request #1789 from 0xProject/fix/order-watcher-race-condition

Fix OrderWatcher race-condition bug
This commit is contained in:
Fabio B 2019-04-24 16:09:58 -05:00 committed by GitHub
commit 18acf50b12
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 0 deletions

View File

@ -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", "version": "4.0.6",
"changes": [ "changes": [

View File

@ -493,6 +493,9 @@ export class OrderWatcher {
private async _emitRevalidateOrdersAsync(orderHashes: string[], transactionHash?: string): Promise<void> { private async _emitRevalidateOrdersAsync(orderHashes: string[], transactionHash?: string): Promise<void> {
for (const orderHash of orderHashes) { for (const orderHash of orderHashes) {
const signedOrder = this._orderByOrderHash[orderHash]; 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 // Most of these calls will never reach the network because the data is fetched from stores
// and only updated when cache is invalidated // and only updated when cache is invalidated
const orderState = await this._orderStateUtils.getOpenOrderStateAsync(signedOrder, transactionHash); const orderState = await this._orderStateUtils.getOpenOrderStateAsync(signedOrder, transactionHash);