Investigating ways to unblock the node thread in JSii

This is a loose copy of the relevant internals from JSii, investigating how to unblock the node thread which currently hangs while waiting for the host.

It replaces the JSON parsing input and accepts strings on standard input.

You can test it with:

npm install
npx tsc && node bin/jsii-runtime

It includes the setTimeout ticker used in the issue repro, so that you can see when node is running / not running.

Commands

  • Most strings will just be echoed back
  • Strings prefixed with completeCallback indicate the completion of a synchronous callback
  • Strings prefixed with b indicate that the start of a blocking callback (to be completed with a matching completeCallback)
  • The exact string defer means to start a promise that starts a sync callback after 1 second