Skip to content

worker: only unref port for stdin if we ref’ed it before

We set the kStartedReading flag from _read() for Worker stdio, and then ref() the port.

However, the .on('end') handler is also attached when ._read() is not called, e.g. when process.stdin inside a Worker is prematurely ended because stdin was not enabled by the parent thread.

In that case, we should not call .unref() for stdin if we did not also call .ref() for it before.

Fixes: https://github.com/nodejs/node/issues/28144

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines

Merge request reports

Loading