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

src: fix Worker termination when --inspect-brk is passed #53724

Merged

Conversation

daeyeon
Copy link
Member

@daeyeon daeyeon commented Jul 4, 2024

Fixes: #53648

When calling node::CreateEnvironment with debug options like --inspect-brk, Environment creation is blocked until an Inspector frontend connects. While creating a Worker thread's Environment, its InspectorAgent, which is owned by the Environment instance and controls exit, is not usable until creation is complete.

This patch allows separate handling of Environment creation and Inspector frontend connection waiting, resolving the issue by creating the Environment instance first in worker threads.

Signed-off-by: Daeyeon Jeong daeyeon.dev@gmail.com

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/startup
@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. labels Jul 4, 2024
@daeyeon daeyeon added inspector Issues and PRs related to the V8 inspector protocol worker Issues and PRs related to Worker support. labels Jul 4, 2024
@daeyeon
Copy link
Member Author

daeyeon commented Jul 4, 2024

/cc @nodejs/cpp-reviewers @nodejs/inspector @nodejs/workers

Signed-off-by: Daeyeon Jeong <daeyeon.dev@gmail.com>
@daeyeon daeyeon force-pushed the main.inspector-240704.Thu.d70e branch from ba88cf2 to 264d531 Compare July 4, 2024 14:31
@daeyeon daeyeon added the request-ci Add this label to start a Jenkins CI on a PR. label Jul 4, 2024
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jul 4, 2024
@nodejs-github-bot

This comment was marked as outdated.

src/inspector_agent.cc Outdated Show resolved Hide resolved
src/node.cc Outdated
Comment on lines 215 to 221
void Environment::WaitForInspectorFrontend() {
if (!inspector_agent_->WaitForConnectByOptions()) {
return;
}

if (inspector_agent_->options().break_node_first_line) {
inspector_agent_->PauseOnNextJavascriptStatement("Break at bootstrap");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I first looked at the function name, I expected it to only wait for the frontend connection. But, it also sets a breakpoint at the first line if specified in the options. Does it make sense for this function to handle setting the breakpoint as well?

Copy link
Member Author

@daeyeon daeyeon Jul 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function name omitted words like 'based on options set at creation', which I initially thought was okay. I renamed it to make it clearer. PTAL.

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@nodejs-github-bot

This comment was marked as outdated.

@H4ad H4ad added the commit-queue Add this label to land a pull request using GitHub Actions. label Jul 5, 2024
Signed-off-by: Daeyeon Jeong <daeyeon.dev@gmail.com>
@daeyeon daeyeon added request-ci Add this label to start a Jenkins CI on a PR. and removed commit-queue Add this label to land a pull request using GitHub Actions. labels Jul 5, 2024
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jul 5, 2024
@nodejs-github-bot

This comment was marked as outdated.

@cola119 cola119 added the request-ci Add this label to start a Jenkins CI on a PR. label Jul 6, 2024
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jul 6, 2024
@cola119 cola119 added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. labels Jul 6, 2024
Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@mcollina mcollina added the commit-queue Add this label to land a pull request using GitHub Actions. label Jul 6, 2024
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Jul 6, 2024
@nodejs-github-bot nodejs-github-bot merged commit e1b80a5 into nodejs:main Jul 6, 2024
63 checks passed
@nodejs-github-bot
Copy link
Collaborator

Landed in e1b80a5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. c++ Issues and PRs that require attention from people who are familiar with C++. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. inspector Issues and PRs related to the V8 inspector protocol lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. worker Issues and PRs related to Worker support.
6 participants