diff options
author | Anna Henningsen <anna@addaleax.net> | 2020-05-18 09:55:17 +0300 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2020-05-22 03:50:04 +0300 |
commit | c45313b3ad47d7e7aa7d204d3ac002a5bbdf3bcb (patch) | |
tree | e1459fbbd15dc42eeefe41f21ef8d3e99d4d9e1c /lib/internal/main | |
parent | b6b82cba27da9ef83bfef67cac9d3593bd72c0e2 (diff) |
worker: perform initial port.unref() before preload modules
The refcount of the internal communication port is relevant for
stdio, but the `port.unref()` call effectively resets any `.ref()`
calls happening during stdio operations happening before it.
Therefore, do the `.unref()` call before loading preload modules,
which may cause stdio operations.
Fixes: https://github.com/nodejs/node/issues/31777
PR-URL: https://github.com/nodejs/node/pull/33455
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Diffstat (limited to 'lib/internal/main')
-rw-r--r-- | lib/internal/main/worker_thread.js | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/internal/main/worker_thread.js b/lib/internal/main/worker_thread.js index ecf5d00c440..6e3935d1382 100644 --- a/lib/internal/main/worker_thread.js +++ b/lib/internal/main/worker_thread.js @@ -92,6 +92,7 @@ if (process.env.NODE_CHANNEL_FD) { port.on('message', (message) => { if (message.type === LOAD_SCRIPT) { + port.unref(); const { argv, cwdCounter, @@ -145,7 +146,6 @@ port.on('message', (message) => { debug(`[${threadId}] starts worker script ${filename} ` + `(eval = ${eval}) at cwd = ${process.cwd()}`); - port.unref(); port.postMessage({ type: UP_AND_RUNNING }); if (doEval) { const { evalScript } = require('internal/process/execution'); |