Repository navigation
fix(session-tree): a function breakpoint no longer hangs a program that forks (#1219) - #1224
Open
debugmcpdev wants to merge 3 commits into
Open
debugmcpdev wants to merge 3 commits into
debugmcpdev wants to merge 3 commits into
Conversation
…at forks (#1219) With any function breakpoint set, a JavaScript program that forks was never given its child session: the row said running for 30 s and then disappeared, the answers said the child had been released to run undebugged, and the program never ended. The fork was stopped on the line breakpoint it had inherited, with no session to resume it. Two defects, one after the other: - js-debug has no setFunctionBreakpoints and sends nothing back for a request it does not know. The fork's connection was sent that request raw, during the adoption and for a set_breakpoint {function} on a child id. An adapter that arms function breakpoints through the CDP bridge arms them in the session's own program only, so a child's are now answered where they are asked: unverified, with a sentence, and nothing is sent. debugpy has the request; Python children keep it. - The clean-up after the failed adoption released nothing: the handshake had gone on to configurationDone after its attach had already failed, so js-debug bound the target to a connection the worker then closed, and the throwaway attach asked for a target that was no longer pending. Every handshake step after the attach is now raced against the attach's failure, so a failed attach ends the handshake while the target is still pending. A failure after configurationDone lets the child go with a disconnect on its own connection. Measured on Windows, Node 24.14.1, js-debug v1.140.0, with the tree fixtures (parent.js, child.js:14, one function breakpoint): before, the fork was still not adopted and the program still running at 82 s; after, the fork stops on line 14 at 2.6 s and the program ends with exit 0. Tests: five unit cases in child-connections.test.ts and one in dap-proxy-worker-child-sessions.test.ts, each red on main's sources, and one real-adapter case in javascript-subprocess-tree.test.ts. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…onDone, a fallback for an unacknowledged disconnect, and the guards under test The independent review found no critical defect and these: - The race against the attach failure is not a gate: a step that had already settled wins over a failure queued beside it. The failure is now also recorded synchronously and checked before configurationDone goes out. - "configurationDone sent" is not "configurationDone processed". When the disconnect on the child's own connection is not acknowledged (the socket is gone, or the adapter never read configurationDone and the target is still pending), the throwaway attach now follows, so this path releases whatever the old one could. - The disconnect is best effort and the comments now say so: read from the upstream sources, js-debug does not resume a reported target it has not started yet when a disconnect reaches it first. - Two guards had no test (the lever check that keeps debugpy on its own path, and the check that leaves a handshake cancelled by close() alone), nor had the release bookkeeping of the new path. Eight cases added; every surviving mutant the review named is now killed. - session-tree.md said a child is re-sent the function breakpoints. Not done here, filed as #1221: the session layer still words a failed adoption as a release without the adapter's acknowledgement. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…f the attach check (#1219) The second, narrow review of the #1219 fix found the change correct and two things nothing held in place: the worker must stay live until the fallback throwaway has detached (dropping the await passed every test), and the attach check must sit right before configurationDone (moved ahead of the steps, it passed too). One case each; both mutants are now killed. Two comments say "bound" where they said "read". Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This was referenced Nov 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1219.
What was wrong
With any function breakpoint set, a JavaScript program that forks never got its child session, and never ended. Measured (Windows 11, Node 24.14.1, js-debug v1.140.0) with the tree fixtures, a breakpoint on
child.js:14and one function breakpoint:runningfor 30 s, then disappears with "1 child process was released to run undebugged (adoption failed…)"child start)Two defects, one after the other:
setFunctionBreakpoints(measured with a bare DAP driver: no response before or after the attach,Unknown requeston its stderr). The program's own target never sees that request (MinimalDapClientserves it from the CDP bridge). A fork's connection has no bridge and was sent it raw, during the adoption and for aset_breakpoint {function}on a child id, and waited out the client's 30 s.attachrequest had itself timed out by then; the handshake went on toconfigurationDoneanyway, js-debug bound the target to that connection and let the fork run, and the worker closed the socket and started a throwaway attach for a target that was no longer pending. The fork ran to its inherited line breakpoint and stayed there.What changes
setFunctionBreakpoints. An adapter that arms function breakpoints through the CDP bridge arms them in the session's own program only. A child's are answered where they are asked: at adoption afunction_breakpoints_syncedstatus reports each one unverified with "Function breakpoints are not armed in a child session…", and afterwardsChildConnections.unarmedFunctionBreakpointsanswers the request fromDapProxyWorker.forwardToChild. Python is unchanged: debugpy has the request.configurationDoneis sent (a race alone lets a step that has already settled win). So the target is still pending when the throwaway attach asks for it.configurationDonefirst tries adisconnecton the child's own connection, the one js-debug binds it to; when nothing acknowledges that, the throwaway attach follows as before. Only for the adoption's own failures under the throwaway lever: a handshake cancelled byclose()keeps its path, and debugpy keeps refusing the held request.Arming function breakpoints in forks is not part of this: it needs the per-target bridge in a fork, and something to hold the fork until a module-scoped name can resolve.
Not done here
disconnectis best effort, and the comments say so. Read from the upstream sources, not reproduced: adisconnectthat reaches js-debug before it has started a reported target does not start it. After the first change above that path needs an adoption that fails in the moments afterconfigurationDone.Tests
tests/proxy/child-connections.test.ts: fifteen cases under "issue javascript (session tree): with a function breakpoint set, a program that forks hangs: the fork's adoption waits 30 s on a setFunctionBreakpoints js-debug never answers, fails, and leaves the fork paused under a closed connection #1219" (no request to a js-debug child, and each function breakpoint reported as not armed; the later request answered by the worker; debugpy still gets the request, and a debugpy attach refused afterconfigurationDonestill refuses the held request; a failed attach never reachesconfigurationDone, also when it fails inside the last step; a failure afterconfigurationDonedisconnects on the child's connection, counts as a release in flight, and falls back to the throwaway when unacknowledged;close()during such a handshake keeps its own path).tests/proxy/dap-proxy-worker-child-sessions.test.ts: the worker answers a fork'ssetFunctionBreakpointsand sends it to neither connection.tests/adapters/javascript/integration/javascript-subprocess-tree.test.ts: a real fork with a function breakpoint on the parent is adopted, stops on its line breakpoint, lists the function breakpoint as not armed, answers a second one the same way, and the tree ends with exit 0. Onmainthe same steps are the first column above (run by hand, not as this test).Review
Two independent reviews, each with a mutation pass, neither finding a critical defect.
close()alone), the race was not a gate, "sent" is not "bound" (hence the throwaway fallback), and the docs said a child is re-sent function breakpoints.Every mutant either review reported as surviving and meaningful is now killed.
Gates
typecheck:all,lint,check-docs,changelog:check. The pre-push run on the pushed commit: unit 434 files, 9575 passed and 7 skipped; integration 47 files, 244 passed and 1 skipped (the JavaScript and Python tree, cascade and attach suites among them).🤖 Generated with Claude Code