Skip to content
This repository has been archived by the owner on Jul 9, 2021. It is now read-only.

BUGFIX: don't remove maker/zrx order from cache twice #357

Merged
merged 1 commit into from Feb 1, 2018
Merged

BUGFIX: don't remove maker/zrx order from cache twice #357

merged 1 commit into from Feb 1, 2018

Conversation

lukeautry
Copy link
Contributor

When removing an order from the watcher cache, we call _removeFromDependentOrderHashes for both the makerTokenAddress and the ZRX token address for fees. The problem is when the makerTokenAddress is the ZRX token address and you call this line:

this._dependentOrderHashes[makerAddress][tokenAddress].delete(orderHash);

This fails and results in the rest of the script terminating.

@LogvinovLeon
Copy link
Contributor

According to the Set docs Set.delete() just returns false and doesn't throw. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/delete
screen shot 2018-02-01 at 12 55 01

@fabioberger
Copy link
Contributor

@LogvinovLeon the issue is that you are trying to call delete on undefined.

@fabioberger
Copy link
Contributor

fabioberger commented Feb 1, 2018

This LGTM. Do we make this same mistake elsewhere?

Would also be great if we could add a regression test for this.

@LogvinovLeon LogvinovLeon merged commit 913930b into 0xProject:development Feb 1, 2018
@lukeautry lukeautry deleted the luke/zrx_order_watch_cache branch February 1, 2018 18:31
this._removeFromDependentOrderHashes(signedOrder.maker, zrxTokenAddress, orderHash);
this._removeFromDependentOrderHashes(signedOrder.maker, signedOrder.makerTokenAddress, orderHash);
if (zrxTokenAddress !== signedOrder.makerTokenAddress) {
this.removeFromDependentOrderHashes(signedOrder.maker, signedOrder.makerTokenAddress, orderHash);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

theres an underscore missing here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How did this compile 😕

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It didn't. But I changed that before publishing

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants