Skip to content

Can't terminate node.js workers #3317

@CPunisher

Description

@CPunisher

Description of Bug

When creating a node.js worker with infinite loop, the main thread cannot terminate the worker.

Steps to Reproduce

Run the following code in stackblitz:

const { Worker } = require("node:worker_threads")

console.log("main start")
const worker = new Worker(`
console.log("worker start")
while (true) {}
`, {eval:true});

setTimeout(() => worker.terminate(), 1000)

Expected Behavior

The process should exit as in real machine.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions