cheminfo / octochemdb

https://octochemdb.cheminfo.org/documentation/static/index.html
MIT License
1 stars 0 forks source link

Piscina abortController not catching error #97

Closed RicardoSilvestr closed 1 year ago

RicardoSilvestr commented 1 year ago

There seems to be an issue with the improveCompoundPool.js function where the try-catch block does not work when the timeout is exceeded. After the restart, the importation works fine. Probably at some point the promise of the compound n+1 (where n is the abort compound) is solved before the promise of compound n, this leads to skip the compound n when cron restarts. We need to investigate and implement a fix.

 /git/docker/node_modules/piscina/dist/src/index.js:571
octochemdb-import-1  |                 reject(new AbortError());
octochemdb-import-1  |                        ^
octochemdb-import-1  | 
octochemdb-import-1  | AbortError: The task has been aborted
octochemdb-import-1  |     at taskInfo.abortListener (/git/docker/node_modules/piscina/dist/src/index.js:571:24)
octochemdb-import-1  |     at AbortSignal.dispatchEvent (/git/docker/node_modules/event-target-shim/dist/event-target-shim.js:818:35)
octochemdb-import-1  |     at abortSignal (/git/docker/node_modules/abort-controller/dist/abort-controller.js:52:12)
octochemdb-import-1  |     at AbortController.abort (/git/docker/node_modules/abort-controller/dist/abort-controller.js:91:9)
octochemdb-import-1  |     at Timeout._onTimeout (file:///git/docker/src/plugins/compounds/sync/utils/improveCompoundPool.js:25:52)
octochemdb-import-1  |     at listOnTimeout (node:internal/timers:569:17)
octochemdb-import-1  |     at process.processTimers (node:internal/timers:512:7)
octochemdb-import-1  | 
octochemdb-import-1  | Node.js v18.15.0
octochemdb-import-1  | 
octochemdb-import-1  | > octochemdb@1.0.0 cron
octochemdb-import-1  | > DEBUG=* node -r dotenv/config src/sync/cron
octochemdb-import-1  | 
octochemdb-import-1  | 2023-04-05T12:37:53.742Z cron sync: /git/docker/src/plugins//taxonomies/sync/syncTaxonomies.js
RicardoSilvestr commented 1 year ago

"...if you're not using await and are instead handling the Promise by appending .then() to it then you'd append a .catch() to that chain to catch failures from within the asynchronous operation. Because a try/catch isn't going to catch an exception that happens from within the asynchronous operation if that operation isn't awaited." explanation