Skip to content

debugger: wait for target startup - #65194

Closed
panva wants to merge 3 commits into
nodejs:mainfrom
panva:debugger-startup-handshake
Closed

debugger: wait for target startup#65194
panva wants to merge 3 commits into
nodejs:mainfrom
panva:debugger-startup-handshake

Conversation

@panva

@panva panva commented Aug 10, 2026

Copy link
Copy Markdown
Member

Important

This ought to deflake parallel/test-debugger-profile and parallel/test-debugger-exceptions.

The inspector can accept a connection before an --inspect-brk target enters its frontend wait. Runtime.runIfWaitingForDebugger can then be handled too early, allowing the target to subsequently block forever.

Wait for NodeRuntime.waitingForDebugger before initializing and releasing launched targets. Race the handshake against disconnects and apply it to both interactive and probe startup.

Refs: #64116
Assisted-by: codex:gpt-5.6-sol

@panva
panva requested a review from joyeecheung August 10, 2026 12:17
@nodejs-github-bot nodejs-github-bot added debugger Issues and PRs related to the debugger subsystem. needs-ci PRs that need a full CI run. labels Aug 10, 2026
The inspector can accept a connection before an --inspect-brk target
enters its frontend wait. Runtime.runIfWaitingForDebugger can then be
handled too early, allowing the target to subsequently block forever.

Wait for NodeRuntime.waitingForDebugger before initializing and
releasing launched targets. Race the handshake against disconnects and
apply it to both interactive and probe startup.

Refs: nodejs#64116
Assisted-by: codex:gpt-5.6-sol
Co-authored-by: Archkon <180910180+Archkon@users.noreply.github.com>
Signed-off-by: Archkon <180910180+Archkon@users.noreply.github.com>
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
@panva
panva force-pushed the debugger-startup-handshake branch from f206372 to 821e267 Compare August 10, 2026 13:25
@panva

panva commented Aug 10, 2026

Copy link
Copy Markdown
Member Author

The startup-readiness handshake and its initial integration were adapted from @Archkon's work in #64304. This version narrows and hardens that approach by covering disconnects during the full handshake, preserving probe-mode structured errors, and adding focused failure and cleanup tests.

@codecov

codecov Bot commented Aug 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.79343% with 26 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.12%. Comparing base (404b0cf) to head (198e386).
⚠️ Report is 111 commits behind head on main.

Files with missing lines Patch % Lines
lib/internal/debugger/inspect_helpers.js 87.69% 18 Missing and 6 partials ⚠️
lib/internal/debugger/inspect_probe.js 83.33% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #65194      +/-   ##
==========================================
- Coverage   90.32%   90.12%   -0.21%     
==========================================
  Files         760      752       -8     
  Lines      248525   251780    +3255     
  Branches    46894    47354     +460     
==========================================
+ Hits       224488   226911    +2423     
- Misses      15469    16210     +741     
- Partials     8568     8659      +91     
Files with missing lines Coverage Δ
lib/internal/debugger/inspect_repl.js 91.34% <100.00%> (+0.03%) ⬆️
lib/internal/debugger/inspect_probe.js 83.06% <83.33%> (+1.01%) ⬆️
lib/internal/debugger/inspect_helpers.js 92.50% <87.69%> (-4.91%) ⬇️

... and 151 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.

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@trivikr trivikr added the flaky-test Issues and PRs related to the tests with unstable failures on the CI. label Aug 11, 2026
@inoway46

inoway46 commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

I ran parallel/test-debugger-exceptions 1,000 times with -j16 on macOS 15:

The A/B result suggests this likely fixes the flake, and the code looks good to me. My only non-blocking nit is the lack of a probe-mode disconnect test while waitForDebugger() is pending. LGTM.

@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@inoway46

inoway46 commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Thanks for adding the probe disconnect test!
I also ran a broader A/B stress test across the debugger tests on macOS 15, repeating each test 100 times.

This suggests that the startup handshake may deflake debugger tests beyond parallel/test-debugger-profile and parallel/test-debugger-exceptions called out in the description.

Additional validation:

stress test for parallel/test-debugger-profile 1,000 times with -j16 on macOS 15:

Comment thread lib/internal/debugger/inspect_helpers.js
Assisted-by: codex:gpt-5.6-sol
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
@panva panva added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. request-ci Add this label to start a Jenkins CI on a PR. labels Aug 16, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Aug 16, 2026
@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

panva added a commit that referenced this pull request Aug 17, 2026
The inspector can accept a connection before an --inspect-brk target
enters its frontend wait. Runtime.runIfWaitingForDebugger can then be
handled too early, allowing the target to subsequently block forever.

Wait for NodeRuntime.waitingForDebugger before initializing and
releasing launched targets. Race the handshake against disconnects and
apply it to both interactive and probe startup.

Refs: #64116
Assisted-by: codex:gpt-5.6-sol
Co-authored-by: Archkon <180910180+Archkon@users.noreply.github.com>
Signed-off-by: Archkon <180910180+Archkon@users.noreply.github.com>
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
PR-URL: #65194
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
@panva

panva commented Aug 17, 2026

Copy link
Copy Markdown
Member Author

Landed in 2004fbd

@panva panva closed this Aug 17, 2026
@panva
panva deleted the debugger-startup-handshake branch August 17, 2026 08:09
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. debugger Issues and PRs related to the debugger subsystem. flaky-test Issues and PRs related to the tests with unstable failures on the CI. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants