abbr / deasync

Turns async function into sync via JavaScript wrapper of Node event loop
MIT License
971 stars 73 forks source link

`import(CJS_USE_DEASYNC)` or `createRequire(import.meta.url)(CJS_USE_DEASYNC)` may leads to endless loop #178

Open loynoir opened 1 year ago

loynoir commented 1 year ago

Reproduce

https://github.com/loynoir/reproduce-node-47971

Expected

$ node ./test/test-require.cjs
waiting import('./plugin.mjs')
waiting import('./plugin.mjs')
waiting import('./plugin.mjs')
waiting import('./plugin.mjs')
waiting import('./plugin.mjs')
waiting import('./plugin.mjs')
waiting import('./plugin.mjs')
waiting import('./plugin.mjs')
waiting import('./plugin.mjs')
waiting import('./plugin.mjs')
waiting import('./plugin.mjs')
{ plugin: [Module: null prototype] { foo: [Function: foo] } }

Actual

$ node ./test/test-import.mjs
waiting import('./plugin.mjs')
waiting import('./plugin.mjs')
waiting import('./plugin.mjs')
...
# endless loop
...
$ node ./test/test-createRequire.mjs
waiting import('./plugin.mjs')
waiting import('./plugin.mjs')
waiting import('./plugin.mjs')
...
# endless loop
...

Related

https://github.com/nodejs/node/issues/47971