Skip to content

worker_threads.terminate results in no response on v12.x #38208

Closed
@zyscoder

Description

@zyscoder

What steps will reproduce the bug?

Setup a node instance,

» node

and run the following javascript code.

worker_threads = require('worker_threads');newWorker = new worker_threads.Worker('str',{eval:true,resourceLimits:{maxYoungGenerationSizeMb:0,maxOldGenerationSizeMb:0}});
arr = [];
for (let i = 0; i < 15000000; i ++) {
    arr.push("num." + i);
}
newWorker.terminate();

Then the node instance stuck and has no response even with "Ctl-D".

How often does it reproduce? Is there a required condition?

This can be triggered following the steps above almost every time. If not, try again, please.

What is the expected behavior?

As the docs said, Stop all JavaScript execution in the worker thread as soon as possible. Returns a Promise for the exit code that is fulfilled when the 'exit' event is emitted..

What do you see instead?

» node
Welcome to Node.js v12.21.0.
Type ".help" for more information.
> worker_threads = require('worker_threads');newWorker = new worker_threads.Worker('str',{eval:true,resourceLimits:{maxYoungGenerationSizeMb:0,maxOldGenerationSizeMb:0}});
Worker {
...
}
> arr = [];
[]
> for (let i = 0; i < 15000000; i ++) {
...     arr.push("num." + i);
... }
15000000
> newWorker.terminate();
^C^C^C^C

                                                                                                                                                                                                 

Additional information

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugIssues with confirmed bugs.workerIssues and PRs related to Worker support.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions