YuzuJS/setImmediate

Referencing `setImmediate` prevents a Deno process from finishing

wvbe opened this issue · 0 comments

wvbe commented

I found this issue working with Deno (v1.23.3) and another library that has a transitive dependency on setimmediate. That bug report is here.

The bug is that if setimmediate is referenced in a Deno script, the deno script will never finish the process normally. Instead, Deno.exit() (similar to NodeJS process.exit()) must be called.

To reproduce:

  • Have Deno installed, or run it from a Docker container (eg. docker run -it --init denoland/deno:ubuntu sh)
  • Create a test.ts file with the following contents:
    import * as setImmediate from 'https://raw.githubusercontent.com/YuzuJS/setImmediate/master/setImmediate.js';
    console.log('End of program', setImmediate);
  • Run using deno run test.ts

Expected:

  • "End of program Module {}" is logged to console
  • The Deno process exits.

Observed:

  • "End of program Module {}" is logged to console
  • The Deno process never exits. It continues to idle.

I'm pretty sure this is caused by the opening of a MessageChannel and setting a message listener for one of the ports; https://github.com/YuzuJS/setImmediate/blob/master/setImmediate.js#L126