Skip to content

inspector: fix connectToMainThread() abort without parent inspector - #65976

Merged
nodejs-github-bot merged 1 commit into
nodejs:mainfrom
codebytere:fix/embedder-connect-to-main-thread-abort
Sep 19, 2026
Merged

nodejs-github-bot merged 1 commit into
nodejs:mainfrom
codebytere:fix/embedder-connect-to-main-thread-abort

Conversation

@codebytere

Copy link
Copy Markdown
Member

inspector.Session#connectToMainThread() in a Worker aborts the process when the parent Environment was created with kNoCreateInspector, which is what an embedder that runs its own inspector (or none) passes: Agent::ConnectToMainThread() reaches CHECK_NOT_NULL(parent_handle_) because a parent without an inspector never hands the Worker a parent handle.

It now throws ERR_INSPECTOR_NOT_AVAILABLE in that case, next to the existing throw for a Worker whose own inspector is not initialized; the code is added to node_errors.h so C++ can raise the error lib already uses.

Tests: EnvironmentTest.WorkerConnectToMainThreadWithoutInspector starts a Worker under a kNoCreateInspector Environment and expects the error code; it aborted before.

Refs: #35025


Disclosure: the code, test and this description were written by Claude Code, directed and reviewed by @codebytere.

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/inspector

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. inspector Issues and PRs related to the V8 inspector protocol. needs-ci PRs that need a full CI run. labels Sep 11, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@codecov

codecov Bot commented Sep 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.00%. Comparing base (1105aec) to head (2b9bb2d).
⚠️ Report is 105 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #65976      +/-   ##
==========================================
- Coverage   90.01%   90.00%   -0.01%     
==========================================
  Files         785      785              
  Lines      269326   269329       +3     
  Branches    51302    51307       +5     
==========================================
- Hits       242431   242419      -12     
- Misses      17392    17408      +16     
+ Partials     9503     9502       -1     
Files with missing lines Coverage Δ
src/inspector_agent.cc 81.34% <100.00%> (+0.20%) ⬆️
src/node_errors.h 86.95% <ø> (ø)

... and 25 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@codebytere
codebytere force-pushed the fix/embedder-connect-to-main-thread-abort branch from e6399c9 to a058629 Compare September 11, 2026 19:24
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@cola119 cola119 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

`inspector.Session#connectToMainThread()` in a Worker aborted the
process on `CHECK_NOT_NULL(parent_handle_)` in
`Agent::ConnectToMainThread()` when the parent Environment was created
with `kNoCreateInspector`, as embedders that run their own inspector
(or none) do.

Throw the new `ERR_INSPECTOR_NOT_AVAILABLE` in that case, next to the
existing throw for a Worker whose own inspector is not initialized.

Refs: nodejs#35025
Signed-off-by: Shelley Vohr <shelley.vohr@gmail.com>
@codebytere
codebytere force-pushed the fix/embedder-connect-to-main-thread-abort branch from a058629 to 2b9bb2d Compare September 13, 2026 11:10
@codebytere codebytere added the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Sep 17, 2026
@codebytere
codebytere requested a review from cola119 September 17, 2026 07:58
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Sep 17, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@codebytere codebytere added the commit-queue PRs queued for automated landing through the Commit Queue. label Sep 19, 2026
@nodejs-github-bot
nodejs-github-bot merged commit e98208b into nodejs:main Sep 19, 2026
72 checks passed
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Landed in e98208b

@nodejs-github-bot nodejs-github-bot removed the commit-queue PRs queued for automated landing through the Commit Queue. label Sep 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. inspector Issues and PRs related to the V8 inspector protocol. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants