Repository navigation
Fix duplicate clientNavigated inspector events on successful SetUrl - #32081
Conversation
|
Updated 6:02 PM PT - Jun 10th, 2026
❌ @robobun, your commit b63f4bd has 1 failures in
🧪 To try this PR locally: bunx bun-pr 32081That installs a local version of the PR into your bun-32081 --bun |
WalkthroughThe SetUrl handler now notifies the inspector inline (constructs pattern and maps route bundle index) and the duplicate helper was removed. A new test asserts the dev server emits exactly one BunFrontendDevServer.clientNavigated event per SetUrl message. ChangesDuplicate inspector event fix
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@test/cli/inspect/BunFrontendDevServer.test.ts`:
- Line 518: The fetch of serverUrl.href that consumes the response blob
(invocation using fetch(serverUrl.href).then(r => r.blob())) is unused and
unclear; either remove this no-op fetch call or, if it is required to prime the
dev server or register routes, add an inline comment explaining its purpose
(e.g., "prime dev server to ensure routes are registered before assertions")
next to the fetch so future readers know why it is present; look for the same
pattern around serverUrl usage in the BunFrontendDevServer.test test helper and
update those occurrences consistently.
- Around line 521-548: The test currently closes the WebSocket (ws.close()) only
after assertions, which can leave the socket open if an assertion fails; wrap
the interaction and assertions that use ws in a try/finally so ws.close() is
invoked regardless of test outcome — i.e., after creating ws via
createHMRClient() and setting up connectedEventPromise, navigated array,
Promise.withResolvers, session.addEventListener and ws event listeners,
immediately enter a try block for sending messages and awaiting
sawSentinelNavigation and performing expect(navigated).toEqual(...), and put
ws.close() in the finally block to ensure cleanup even on failure.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: b4e539b6-3546-4ed9-bfca-125ccd006bf5
📒 Files selected for processing (2)
src/runtime/bake/DevServer/HmrSocket.rstest/cli/inspect/BunFrontendDevServer.test.ts
💤 Files with no reviewable changes (1)
- src/runtime/bake/DevServer/HmrSocket.rs
9fe5653 to
b63f4bd
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@test/cli/inspect/BunFrontendDevServer.test.ts`:
- Line 520: The test uses a fetch chain with .then(r => r.blob()) (in
BunFrontendDevServer.test.ts where serverUrl.href is used); change it to use
async/await by replacing await fetch(serverUrl.href).then(r => r.blob()) with
await (await fetch(serverUrl.href)).blob(); update all similar occurrences in
the file so the code follows the async/await pattern and avoids .then chains.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 58e8e97e-e61e-40e7-8cd8-c167df5d1a77
📒 Files selected for processing (2)
src/runtime/bake/DevServer/HmrSocket.rstest/cli/inspect/BunFrontendDevServer.test.ts
Restore src/runtime/bake/DevServer/HmrSocket.rs and test/cli/inspect/BunFrontendDevServer.test.ts to their state on main. The branch accidentally re-added the duplicate clientNavigated inspector notify and deleted the guard test, both from #32081.
Fixes #32080
Problem
The HMR socket's
SetUrlhandler notified the inspector'sBunFrontendDevServer.clientNavigatedtwice for a successful navigation to a new route bundle: once inline right afterroute_to_bundle_index_slow, and again vianotify_inspector_client_navigationafterSetUrlResponsewas sent. Both events carried identical payloads. OneSetUrlmessage over/_bun/hmrproduced:The failed-lookup and same-route paths correctly sent a single event. Both calls date back to the original inspector support in 570e6b7 (#19340); the Rust port reproduced the behavior faithfully.
Fix
Remove the trailing
notify_inspector_client_navigationcall in theSetUrlarm ofHmrSocket::on_message. The inline notify already fires exactly once for everySetUrl, with the correctrouteBundleIdon all three paths (new route, same route, failed lookup withrouteBundleIdabsent). The helper had no remaining callers, so it is deleted.Note: this issue surfaced during review of #32076, which has since merged; this branch is rebased on top of it.
Verification
New test in
test/cli/inspect/BunFrontendDevServer.test.tssends oneSetUrlfor a matched route followed by one for an unknown route (an ordering sentinel, since inspector events are emitted synchronously and delivered in order), then asserts exactly oneclientNavigatedper message, including that the failed lookup still reports a single event with norouteBundleId.On the unfixed build the test fails with two identical
/secondevents; with the fix the whole file passes (6 pass, 2 todo).