Repository navigation
fix(test): keep the fake Inspector's discovery sockets alive - #8609
XiaoBinGan wants to merge 1 commit into
Conversation
`tests/boundary/mcp/javascriptRuntimeObservationMcp.test.ts` fails on main at
the direct-observation assertion with `endpoint_unreachable` /
`ECONNRESET`, so the second CDP connection never opens and the case stops
before it can compare the two evidence IDs.
The cause is not the observation path. The first `get_evidence_bundle` call
in a process - which that test now performs before the direct observation -
spends ~8.4s compiling the tool output schema inside the MCP client. Measured:
BUNDLE-CALL 1 ms= 8490
BUNDLE-CALL 2 ms= 1
setInterval(100ms) ticks during call 1: 0
`node --cpu-prof` attributes the time to `@modelcontextprotocol/client`'s Ajv
provider (`addNames` 2.3s, `compileSchema` 1.0s, plus codegen), so the event
loop is blocked synchronously, not waiting on I/O.
The fake Inspector's in-process HTTP server keeps Node's 5s keep-alive
default. While the loop is blocked that timeout expires, the server retires
the pooled discovery socket, and the provider's next CDP upgrade reuses the
retired socket and is reset.
Evidence that this is the mechanism rather than the assertions:
- replacing the block with a synchronous 8s spin reproduces the failure (2/2);
- replacing it with async 6s / 10s / 15s delays does not (5/5 pass);
- the fixture's CDP endpoint and WebSocket URL both answer correctly right
before the direct observation, so discovery state is intact.
Raise the fixture server's keep-alive window so an in-process caller that
blocks the loop cannot retire a socket a later caller still holds. The fake
is not modelling an idle-connection policy, so it has no reason to enforce
Node's default there.
The MCP case now passes 3/3 for three consecutive runs. It fails 4/4 on
unmodified main. The other five files that use this fixture are unchanged: the
two that still fail (`javascriptRuntimeObservation.test.ts`,
`javascriptRuntimeUnresolvedTarget.test.ts`) fail identically with and without
this change, so they are unrelated.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
[Low impact] The fixture-only change appears safe to merge. SummaryRaises the fake Inspector’s HTTP keep-alive timeout to 120 seconds so discovery sockets survive synchronous work between test calls.
Reviews (1) · Last reviewed commit: "fix(test): keep the fake Inspector's dis..." · Reviewed by Greptile |
|
Folding this into #8592, which now carries both remaining fixes. Neither PR can go green alone: every PR's merge ref inherits both #8573 failures plus the Frida fixture one, so splitting them just deadlocks both. #8592 + your #8596 is the pair that makes main green — or #8592 alone if you'd rather I keep the Frida fixture change out of it. |
Summary
tests/boundary/mcp/javascriptRuntimeObservationMcp.test.tsfails on currentmainat the direct-observation assertion. The second CDP connection never opens —endpoint_unreachable, causeECONNRESET— so the case stops before it can compare the direct evidence ID against the MCP one.The cause is not the observation path.
7bcefead6(#8573) added aget_evidence_bundlecall to that test before the direct observation, and the first such call in a process spends ~8.4s compiling the tool output schema inside the MCP client. That blocks the event loop synchronously; the fake Inspector's in-process HTTP server keeps Node's 5s keep-alive default, retires the pooled discovery socket while the loop is blocked, and the provider's next CDP upgrade reuses the retired socket and is reset.This raises the fixture server's keep-alive window so an in-process caller that blocks the loop cannot retire a socket a later caller still holds. The fake is not modelling an idle-connection policy, so there is no reason for it to enforce Node's default there.
This is the third and last independent failure blocking
main; the formatting half is #8592 and the Frida fixture half is #8595 / #8596. All three must land formainto be green again. I raised this diagnosis in #8596 first and am sending it because it is the one that had no fix.Problem and expected behavior
On a pristine
mainatd3ab0faf5:Expected: 3 passed. That is now the result, 3/3 for three consecutive runs.
Change and scope
One line plus a comment in
tests/fixtures/inspector/fakeV8Inspector.ts:The
httpserver there serves/json/versionand/json/listfor the fixture's loopback endpoint. Nothing else in the fixture changes; no assertion, timeout, or stub value is touched, and the test itself is unmodified.Contract and boundary impact
main.Expected effects (check known effects; use documentation-only on its own).
Evidence and regression coverage
javascriptRuntimeObservationMcp.test.tsexecute again.d3ab0faf5; 3/3 pass with this change.Mechanism evidence, all measured on this host with Node 24.22.1:
get_evidence_bundlefirst callsetInterval(100ms)ticks during that first callnode --cpu-proftop self-time@modelcontextprotocol/clientAjvaddNames2.3s,compileSchema1.0s, codegen/json/version,/json/list, and a raw CDP WebSocket connect immediately before the direct observationValidation performed
node node_modules/vitest/vitest.mjs run tests/boundary/mcp/javascriptRuntimeObservationMcp.test.ts— 3 passed, 3 consecutive runs (4 failed on base)node scripts/run-typescript.mjs --noEmit— exit 0npx oxfmt --check tests/fixtures/inspector/fakeV8Inspector.ts—All matched files use the correct format.javascriptRuntimeObservation.test.ts,javascriptRuntimeUnresolvedTarget.test.ts) still fail, but they fail identically with the change reverted, so this PR does not affect them.Compatibility, safety, and release
Author readiness
Human owner: @XiaoBinGan
Before merge
type(scope): outcome.