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

OrderWatcher returns an error and stop working after that #1710

Closed
valkyriaivan opened this issue Mar 18, 2019 · 5 comments
Closed

OrderWatcher returns an error and stop working after that #1710

valkyriaivan opened this issue Mar 18, 2019 · 5 comments
Assignees

Comments

@valkyriaivan
Copy link

valkyriaivan commented Mar 18, 2019

Expected Behavior

The orderWatcher should do the callback without errors when and order is expired.

Current Behavior

The orderWatcher returns an error and stops checking the orders status after that, even if more orders are added.

TypeError: Cannot read property 'makerAssetData' of undefined
   at OrderWatcher._cleanupOrderRelatedState (/usr/local/app/node_modules/@0x/order-watcher/src/order_watcher/order_watcher.ts:290:50)
   at OrderWatcher.<anonymous> (/usr/local/app/node_modules/@0x/order-watcher/src/order_watcher/order_watcher.ts:234:18)
   at step (/usr/local/app/node_modules/@0x/order-watcher/lib/src/order_watcher/order_watcher.js:43:23)
   at Object.next (/usr/local/app/node_modules/@0x/order-watcher/lib/src/order_watcher/order_watcher.js:24:53)
   at fulfilled (/usr/local/app/node_modules/@0x/order-watcher/lib/src/order_watcher/order_watcher.js:15:58)
   at process._tickCallback (internal/process/next_tick.js:68:7)

Steps to Reproduce

I can't reproduce the error since it happens at random times during the cycle.

Context

I create orders every 30 minutes for some days and the orderWatcher delete those when they expire. After sometimes 2-3 hours or a day(it's not arbitrary), an error is given by the subscribe callback and the watcher stops checking the orders status.
I checked the orders before adding them and they are fine. The orders are created from a bot, so it's not imput human error

Your Environment

Package Version
0x.js ^2.0.4
@0x/order-watcher ^4.0.3
Nodejs 10.15.3
Network
ropsten
@fabioberger
Copy link
Contributor

Thanks for reporting this issue @valkyriaivan. This looks to me like a potential race-condition. Will work on confirming that hunch and fixing the issue.

@valkyriaivan
Copy link
Author

@fabioberger Any updates on this issue? Was it confirmed your hunch? I'm just curious to know if it is a problem from my integration.
If it has to be fixed, I'll try to find an older version where this doesn't happen and wait for the fix to come. Which version might be safe?

@valkyriaivan
Copy link
Author

I have updated the order watcher to 4.0.5 and a similar error keeps happening, now it gives more info about the error so I'll provide it in case it helps. It seems to be an internal error since it is never returned in the callback.

(node:7) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'takerAddress' of undefined
    at OrderStateUtils.<anonymous> (/usr/local/app/node_modules/@0x/order-utils/src/order_state_utils.ts:167:25)
    at step (/usr/local/app/node_modules/@0x/order-utils/lib/src/order_state_utils.js:43:23)
    at Object.next (/usr/local/app/node_modules/@0x/order-utils/lib/src/order_state_utils.js:24:53)
    at /usr/local/app/node_modules/@0x/order-utils/lib/src/order_state_utils.js:18:71
    at new Promise (<anonymous>)
    at __awaiter (/usr/local/app/node_modules/@0x/order-utils/lib/src/order_state_utils.js:14:12)
    at OrderStateUtils.getOpenOrderRelevantStateAsync (/usr/local/app/node_modules/@0x/order-utils/lib/src/order_state_utils.js:184:16)
    at OrderStateUtils.<anonymous> (/usr/local/app/node_modules/@0x/order-utils/src/order_state_utils.ts:123:47)
    at step (/usr/local/app/node_modules/@0x/order-utils/lib/src/order_state_utils.js:43:23)
    at Object.next (/usr/local/app/node_modules/@0x/order-utils/lib/src/order_state_utils.js:24:53)
    at /usr/local/app/node_modules/@0x/order-utils/lib/src/order_state_utils.js:18:71
    at new Promise (<anonymous>)
    at __awaiter (/usr/local/app/node_modules/@0x/order-utils/lib/src/order_state_utils.js:14:12)
    at OrderStateUtils.getOpenOrderStateAsync (/usr/local/app/node_modules/@0x/order-utils/lib/src/order_state_utils.js:131:16)
    at OrderWatcher.<anonymous> (/usr/local/app/node_modules/@0x/order-watcher/src/order_watcher/order_watcher.ts:498:60)
    at step (/usr/local/app/node_modules/@0x/order-watcher/lib/src/order_watcher/order_watcher.js:43:23)
    at Object.next (/usr/local/app/node_modules/@0x/order-watcher/lib/src/order_watcher/order_watcher.js:24:53)
    at fulfilled (/usr/local/app/node_modules/@0x/order-watcher/lib/src/order_watcher/order_watcher.js:15:58)
    at process._tickCallback (internal/process/next_tick.js:68:7)

@fabioberger
Copy link
Contributor

Thanks for reporting @valkyriaivan. Looked into this second issue and it is indeed another race condition. I've opened a PR with a fix.

@fabioberger
Copy link
Contributor

Fixed it. Going to publish a new version of the package in the next day or two.

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

No branches or pull requests

3 participants