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

worker_threads stuck when passed execArgv: ["--inspect-brk"] #53648

Closed
AriPerkkio opened this issue Jun 30, 2024 · 1 comment · Fixed by #53724
Closed

worker_threads stuck when passed execArgv: ["--inspect-brk"] #53648

AriPerkkio opened this issue Jun 30, 2024 · 1 comment · Fixed by #53724
Labels
inspector Issues and PRs related to the V8 inspector protocol worker Issues and PRs related to Worker support.

Comments

@AriPerkkio
Copy link

Version

v20.15.0

Platform

Darwin Aris-MacBook-Air.local 23.5.0 Darwin Kernel Version 23.5.0: Wed May  1 20:19:05 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T8112 arm64

Subsystem

No response

What steps will reproduce the bug?

// worker-repro.mjs
import { isMainThread, Worker } from "node:worker_threads";
import { fileURLToPath } from "node:url";

if (isMainThread) {
  const worker = new Worker(fileURLToPath(import.meta.url), {
    execArgv: ["--inspect-brk"],
  });
  await new Promise((r) => setTimeout(r, 1_000));

  setTimeout(() => {
    console.log("Time out waiting for terminate, calling process.exit()");
    process.exit();
  }, 1000).unref();

  setTimeout(
    () => console.log("This is never logged but process.exit doesnt exit"),
    2000
  ).unref();

  console.log("Terminating...");
  await worker.terminate();
  console.log("Done");
} else {
  console.log("Worker running");
}

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

Always on 20.15.0. Works fine on 20.14.0.

What is the expected behavior? Why is that the expected behavior?

  • Worker should start
  • Worker should exit
  • Main thread should exit
ari ~/Git/repros  $ nvm use 20.14.0
Now using node v20.14.0 (npm v10.7.0)
ari ~/Git/repros  $ node worker-repro.mjs 
Worker running
Terminating...
Done

What do you see instead?

  • Worker does not start
  • worker.terminate() is stuck
  • process.exit() does not exit the main process
ari ~/Git/repros  $ node worker-repro.mjs 
Terminating...
Time out waiting for terminate, calling process.exit()
# Stuck here forever, exits on CTRL+c

Additional information

Even though --inspect-brk doesn't work on workers (#26609 (comment)), it still shouldn't make them stuck.

@AriPerkkio AriPerkkio changed the title worker_thread stuck when passed execArgv: ["--inspect-brk"] worker_threads stuck when passed execArgv: ["--inspect-brk"] Jun 30, 2024
@ajvincent
Copy link

Possibly the same bug: #53681
(I realize this because I know the module loader hooks run on a dedicated thread)

@RedYetiDev RedYetiDev added inspector Issues and PRs related to the V8 inspector protocol worker Issues and PRs related to Worker support. labels Jul 2, 2024
aduh95 pushed a commit that referenced this issue Jul 12, 2024
Signed-off-by: Daeyeon Jeong <daeyeon.dev@gmail.com>
PR-URL: #53724
Fixes: #53648
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Kohei Ueno <kohei.ueno119@gmail.com>
aduh95 pushed a commit that referenced this issue Jul 16, 2024
Signed-off-by: Daeyeon Jeong <daeyeon.dev@gmail.com>
PR-URL: #53724
Fixes: #53648
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Kohei Ueno <kohei.ueno119@gmail.com>
marco-ippolito pushed a commit that referenced this issue Aug 19, 2024
Signed-off-by: Daeyeon Jeong <daeyeon.dev@gmail.com>
PR-URL: #53724
Fixes: #53648
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Kohei Ueno <kohei.ueno119@gmail.com>
marco-ippolito pushed a commit that referenced this issue Aug 19, 2024
Signed-off-by: Daeyeon Jeong <daeyeon.dev@gmail.com>
PR-URL: #53724
Fixes: #53648
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Kohei Ueno <kohei.ueno119@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
inspector Issues and PRs related to the V8 inspector protocol worker Issues and PRs related to Worker support.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants