-
-
Notifications
You must be signed in to change notification settings - Fork 35.2k
Closed as not planned
Closed as not planned
Copy link
Labels
wontfixIssues that will not be fixed.Issues that will not be fixed.workerIssues and PRs related to Worker support.Issues and PRs related to Worker support.
Description
Version
v20.12.0
Platform
Darwin toyobayashiM2Pro.local 23.4.0 Darwin Kernel Version 23.4.0: Fri Mar 15 00:12:49 PDT 2024; root:xnu-10063.101.17~1/RELEASE_ARM64_T6020 arm64
Subsystem
worker_threads
What steps will reproduce the bug?
-
Create
index.jsprocess.once('beforeExit', () => { console.log('beforeExit') }) const { Worker } = require('worker_threads') const w = new Worker(` const { parentPort } = require('worker_threads'); parentPort.on('message', (msg) => { parentPort.postMessage(msg); }); `, { eval: true }) // w.on('message', () => {}) // <--- enable this line to let Node.js exit w.unref() w.on('message', () => {}) // <--- or comment this line to let Node.js exit
-
Run
node ./index.js
How often does it reproduce? Is there a required condition?
Always
What is the expected behavior? Why is that the expected behavior?
worker.unref() make Node.js exit no matter where worker.on('message', () => {}) appear.
What do you see instead?
Node.js process stuck forever.
Additional information
w.on('message', () => {})
w.unref()
w.on('message', () => {})
// ✅ exitw.unref()
w.on('message', () => {})
// ❗️ stuckw.on('message', () => {})
w.unref()
// ✅ exitw.unref()
// ✅ exitNot sure if this is expected behavior.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
wontfixIssues that will not be fixed.Issues that will not be fixed.workerIssues and PRs related to Worker support.Issues and PRs related to Worker support.