Repository navigation
fix: Vite SSR bindings out of JavaScript locals (#1215); attach verification keeps its window and its hint (#1213) - #1228
Open
debugmcpdev wants to merge 3 commits into
Open
debugmcpdev wants to merge 3 commits into
debugmcpdev wants to merge 3 commits into
Conversation
Vite's SSR runner, which vitest runs every module through, binds each import of a module as __vite_ssr_import_<n>__ (beside __vite_ssr_exports__, __vite_ssr_import_meta__ and others) in the scope the module's functions close over. At a stop under vitest they took the stop snapshot's slots before the function's own variables and padded get_local_variables. They are the transform's, not the program's, the way a C# display class is the compiler's: JsDebugAdapterPolicy.extractLocalVariables leaves them out unless includeSpecial is set, and a scope that held nothing else supplies nothing (so it is not listed as a contributing scope). Measured with a real vitest run, a breakpoint in tree-settle.ts: 11 locals with two __vite_ssr_import_* among them before, 9 and none after; includeSpecial lists them as before. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…n is not sent to restart_debugging (#1213) Two defects in one error message: Attach did not become debuggable: no threads reported within 20000ms (last failure: Debug adapter did not respond to 'threads' request within 25s. ... Try restart_debugging to relaunch the session. ...) - The verification's threads request is bounded by the window, and the worker keeps that bound. A worker that answers nothing at all (here it was itself stopped at a breakpoint) is caught only by the parent's backstop, a five second margin later, so the call outlived its verifyTimeout and quoted a longer time than the one it had been given. verifyAttachThreads now stops waiting when the window closes (plus 250 ms for the worker's own timeout to cross the IPC channel and be the failure that is quoted), and the abandoned request's late rejection is handled. - dapRequestTimeout told every session to try restart_debugging, which replays a launch and refuses an attach session. The proxy manager knows how it was started: for an attach the message says to attach again with attach_to_process. verifyAttachThreads had no unit test of its own; it has one now. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
…t hint that is true for every session (#1213) An independent review of the previous commit, with a mutation pass. Nothing critical or important. - The hint. The previous commit chose between "restart_debugging" and "attach_to_process" from the proxy configuration's attach flag. That flag is also set by a launch whose arguments are attach-shaped, which restart_debugging does replay; and a child session's requests travel on its root's worker, so a child was sent to a tool that refuses a child id. The layer that words this cannot tell the kinds apart, so it no longer guesses: one sentence names each way back and whose it is. The flag on ProxyManager is gone. - The changelog said attach_to_process "answers by its verifyTimeout". Read from the code by the reviewer: the verification now returns at its window (plus the 250 ms grace), but the failure that follows still has to stop a worker that answers nothing, which drains the abandoned request for one second and then waits out the worker's stop bound. The entry says what is true: the verification keeps to its window and no longer contradicts itself. - The comment on sendThreadsRequestBounded explained why the request was never raced against a local timer. That price is paid again in the one case the request's own bound cannot cover; the comment says so. - A test that the window's timer is cleared when the debugger answers (a mutant that dropped the clear survived). Not changed: an answer that reaches the parent more than 250 ms after the request's bound is now discarded where it used to be taken. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
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 #1215 and #1213. Two small fixes from the same self-debugging run, independent of the session-tree PRs: one commit for #1215, two for #1213 (the fix, then the answers to its review).
#1215: Vite's module bindings filled the locals of a stop under vitest
Vite's SSR runner, which vitest runs every module through, binds each import of a module as
__vite_ssr_import_<n>__(beside__vite_ssr_exports__,__vite_ssr_import_meta__and others) in the scope the module's functions close over. At a stop under vitest they took the stop snapshot's slots before the function's own variables and paddedget_local_variables.JsDebugAdapterPolicy.extractLocalVariablesnow leaves out names with the__vite_ssr_prefix unlessincludeSpecialis set, the way the .NET policy leaves out compiler-generated names. A scope that held nothing else supplies nothing, so it is not listed as a contributing scope.Measured with a real vitest run (
vitest run tests/core/unit/session/tree-settle.test.ts, a breakpoint insrc/session/execution/tree-settle.ts; Windows 11, Node 24.14.1):get_local_variables__vite_ssr_import_*snapshot.localsincludeSpecial: true__vite_ssr_import_*__vite_ssr_import_*Only the measured prefix is filtered. Other runners' bindings (vitest's
__vi_import_*for hoisted mocks, for one) were not observed and are not touched.#1213: the attach verification outlived its window, and the timeout hint sent every session to
restart_debuggingThe message, from a run where the proxy worker was itself stopped at a breakpoint:
threadsrequest is bounded by the window and the worker keeps that bound. A worker that answers nothing at all is caught only by the parent's backstop, a five second margin later, so the verification returned after 25 s and quoted a longer time than it had been given.verifyAttachThreadsnow stops waiting when the window closes, plus 250 ms for the worker's own timeout to cross the IPC channel and remain the failure that is quoted.attach_to_processas a whole still outlivesverifyTimeoutin that case, by less than before. This is the reviewer's reading of the code, not a measurement, and the changelog entry was reworded to claim only what is true.ErrorMessages.dapRequestTimeouttold every session to tryrestart_debugging, which replays a launch and refuses an attach session and a child session. My first version chose between two sentences from the proxy configuration's attach flag; the review showed that flag is also set by a launch with attach-shaped arguments (whichrestart_debuggingdoes replay) and that a child session's requests travel on its root's worker. The layer that words the message cannot tell the kinds apart, so it no longer guesses: "To go on, start the program again: restart_debugging if this session was started with start_debugging, attach_to_process if it was attached (restart_debugging refuses an attach session); a child session comes back with its parent."Not changed: the request keeps the whole remaining window as its bound (an adapter that answers
threadsslowly but within the window still succeeds, as before). An answer that reaches the parent more than 250 ms after that bound is now discarded where it used to be taken.The live case (a worker stopped at a breakpoint) was not re-run; the unit test stands in for it with a request that nothing answers.
Review
One independent review of the #1213 commit with a mutation pass (8 mutants, 6 killed; of the two survivors one is equivalent and the other, the window timer's clear, now has a test). Nothing critical or important; its points are the second bullet, the hint, a stale comment, and the changelog wording, all answered in the third commit. The #1215 commit has had no independent review.
Tests
tests/unit/shared/adapter-policy-js.test.ts: the bindings are left out, a look-alike program name stays, a scope emptied by the filter is not a contributing scope,includeSpeciallists them.tests/core/unit/session/attach/attach-verification.test.ts(new;verifyAttachThreadshad no unit test of its own): the threads answer and its bound, polling again on zero threads, returning by the window's end when nothing answers, the worker's own timeout still quoted, no unhandled rejection from the abandoned request, the adapter going away, no timer left behind.tests/unit/utils/error-messages.test.ts: the one wording, naming each way back.Gates
typecheck:all,lint,check-docs,changelog:check. The pre-push run on the pushed commit: unit 435 files, 9568 passed and 7 skipped; integration 47 files, 243 passed and 1 skipped.🤖 Generated with Claude Code