Skip to content

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

Description

@AriPerkkio

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    inspectorIssues and PRs related to the V8 inspector protocol.workerIssues and PRs related to the worker_threads module and Worker API.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions