Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run worker threads with --v8-pool-size=0 #42523

Closed
daeyeon opened this issue Mar 30, 2022 · 0 comments · Fixed by #45513
Closed

Run worker threads with --v8-pool-size=0 #42523

daeyeon opened this issue Mar 30, 2022 · 0 comments · Fixed by #45513
Labels
worker Issues and PRs related to Worker support.

Comments

@daeyeon
Copy link
Member

daeyeon commented Mar 30, 2022

Version

v18.0.0-pre

What steps will reproduce the bug?

// Flags: --v8-pool-size=0
const { Worker, isMainThread } = require('worker_threads');

if (isMainThread) {
  console.log('[main thread]');

  const worker = new Worker(__filename);
  worker.on('exit', (exitCode) => { console.log('worker exited with', exitCode); });
  process.on('exit', (exitCode) => { console.log('main thread exited with', exitCode); });
} else {
  console.log('[worker]');
}

Run a file including the above script with --v8-pool-size=0 cli option.

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

I guess it always occurs when running any script using worker_threads with --v8-pool-size=0.

What is the expected behavior?

[main thread]
[worker]
worker exited with 0
main thread exited with 0

What do you see instead?

[main thread]
[worker]
daeyeon added a commit to daeyeon/node that referenced this issue Mar 30, 2022
fix: nodejs#42523

Problem:
If no platform worker exists, Node.js doesn't shut down when background
tasks exist. It keeps waiting in `NodePlatform::DrainTasks`.

Observation:
It seems that Node.js used to use V8's `DefaultPlatform` implementation,
which chooses a suitable default value in case that `--v8-pool-size=0`
is given as a command-line option. However, Node.js currently uses its
own v8::Platform implementation, `NodePlatform`. It doesn't have the
logic to handle the case.

I referred to nodejs#4344 to track the issue.
@VoltrexKeyva VoltrexKeyva added the worker Issues and PRs related to Worker support. label Mar 31, 2022
daeyeon added a commit to daeyeon/node that referenced this issue Apr 14, 2022
fix: nodejs#42523

Problem:
If no platform worker exists, Node.js doesn't shut down when background
tasks exist. It keeps waiting in `NodePlatform::DrainTasks`.

Observation:
It seems that Node.js used to use V8's `DefaultPlatform` implementation,
which chooses a suitable default value in case that `--v8-pool-size=0`
is given as a command-line option. However, Node.js currently uses its
own v8::Platform implementation, `NodePlatform`. It doesn't have the
logic to handle the case.

I referred to nodejs#4344 to track the issue.
daeyeon added a commit to daeyeon/node that referenced this issue Apr 22, 2022
fix: nodejs#42523

Problem:
If no platform worker exists, Node.js doesn't shut down when background
tasks exist. It keeps waiting in `NodePlatform::DrainTasks`.

Observation:
It seems that Node.js used to use V8's `DefaultPlatform` implementation,
which chooses a suitable default value in case that `--v8-pool-size=0`
is given as a command-line option. However, Node.js currently uses its
own v8::Platform implementation, `NodePlatform`. It doesn't have the
logic to handle the case.

I referred to nodejs#4344 to track the issue.
nodejs-github-bot pushed a commit that referenced this issue Nov 21, 2022
It doesn't terminate when any pending V8 tasks exist if no thread
is in the pool.

This allocates one thread at least for V8's background tasks if
`--v8-pool-size=0` is given as a CLI option.

Signed-off-by: Daeyeon Jeong <daeyeon.dev@gmail.com>
PR-URL: #45513
Fixes: #42523
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
ruyadorno pushed a commit that referenced this issue Nov 21, 2022
It doesn't terminate when any pending V8 tasks exist if no thread
is in the pool.

This allocates one thread at least for V8's background tasks if
`--v8-pool-size=0` is given as a CLI option.

Signed-off-by: Daeyeon Jeong <daeyeon.dev@gmail.com>
PR-URL: #45513
Fixes: #42523
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
marco-ippolito pushed a commit to marco-ippolito/node that referenced this issue Nov 23, 2022
It doesn't terminate when any pending V8 tasks exist if no thread
is in the pool.

This allocates one thread at least for V8's background tasks if
`--v8-pool-size=0` is given as a CLI option.

Signed-off-by: Daeyeon Jeong <daeyeon.dev@gmail.com>
PR-URL: nodejs#45513
Fixes: nodejs#42523
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
danielleadams pushed a commit that referenced this issue Dec 30, 2022
It doesn't terminate when any pending V8 tasks exist if no thread
is in the pool.

This allocates one thread at least for V8's background tasks if
`--v8-pool-size=0` is given as a CLI option.

Signed-off-by: Daeyeon Jeong <daeyeon.dev@gmail.com>
PR-URL: #45513
Fixes: #42523
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
danielleadams pushed a commit that referenced this issue Dec 30, 2022
It doesn't terminate when any pending V8 tasks exist if no thread
is in the pool.

This allocates one thread at least for V8's background tasks if
`--v8-pool-size=0` is given as a CLI option.

Signed-off-by: Daeyeon Jeong <daeyeon.dev@gmail.com>
PR-URL: #45513
Fixes: #42523
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
danielleadams pushed a commit that referenced this issue Jan 3, 2023
It doesn't terminate when any pending V8 tasks exist if no thread
is in the pool.

This allocates one thread at least for V8's background tasks if
`--v8-pool-size=0` is given as a CLI option.

Signed-off-by: Daeyeon Jeong <daeyeon.dev@gmail.com>
PR-URL: #45513
Fixes: #42523
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
danielleadams pushed a commit that referenced this issue Jan 4, 2023
It doesn't terminate when any pending V8 tasks exist if no thread
is in the pool.

This allocates one thread at least for V8's background tasks if
`--v8-pool-size=0` is given as a CLI option.

Signed-off-by: Daeyeon Jeong <daeyeon.dev@gmail.com>
PR-URL: #45513
Fixes: #42523
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
danielleadams pushed a commit that referenced this issue Jan 5, 2023
It doesn't terminate when any pending V8 tasks exist if no thread
is in the pool.

This allocates one thread at least for V8's background tasks if
`--v8-pool-size=0` is given as a CLI option.

Signed-off-by: Daeyeon Jeong <daeyeon.dev@gmail.com>
PR-URL: #45513
Fixes: #42523
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
worker Issues and PRs related to Worker support.
Projects
None yet
2 participants