Skip to content

fix(web-ui): keep the settings scene routing test off the real transport - #2397

Merged
bobleer merged 1 commit into
GCWing:1.0.0-explorefrom
bobleer:bob/settings-scene-test-transport-leak-explore
Aug 20, 2026
Merged

fix(web-ui): keep the settings scene routing test off the real transport#2397
bobleer merged 1 commit into
GCWing:1.0.0-explorefrom
bobleer:bob/settings-scene-test-transport-leak-explore

Conversation

@bobleer

@bobleer bobleer commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator

Summary

Frontend Build can fail with every web UI test passing:

Test Files  490 passed (490)
Tests  3627 passed (3627)
Errors  1 error

EnvironmentTeardownError: [vitest-worker]: Closing rpc while "onUserConsoleLog" was pending
This error originated in "src/app/scenes/settings/SettingsScene.test.tsx"

SettingsScene mounts useExternalAppAwareness, which calls the external sources API on mount. Outside Tauri createTransportAdapter() resolves to the WebSocket adapter, so the routing test opens a real socket to ws://localhost:8080/ws; the connection fails, and scheduleReconnect keeps retrying and logging on a timer that outlives the file. A console write from that timer reaching a worker whose rpc is already closing is what fails the job — the test file itself is green.

It only surfaces on a runner slow enough for the lookup to reach the transport before the file ends, which is why it reads as an intermittent flake rather than a broken test.

This mocks the hook, the way the file already mocks every panel it renders. Tab routing is what it covers; the awareness lookup is chrome it never asserts on.

Type and Areas

Type: regression fix (test)

Areas: web UI

Motivation / Impact

Removes a CI failure mode that can hit any PR and is invisible in the test summary. No product code changes.

Verification

Reproduced on this branch first, then fixed. Reproduced deterministically by copying the file, stubbing the WebSocket global to record constructions, and draining macrotasks after the first test the way a slower runner would:

before: PROBE sockets opened: ["ws://localhost:8080/ws"]
after:  PROBE sockets opened: []
pnpm --dir src/web-ui run test:run src/app/scenes/settings/SettingsScene.test.tsx   # 7 passed

Reviewer Notes

Port of #2393 (merged to main as b3eb18b). This branch carries the same scene and the same test file, and the probe reproduces the socket here too, so the leak is present independently of that merge.

The adapter's retry loop is doing what it should — the bug is that a unit test reached it at all. If it is worth going further, a shared vitest setup that stubs the transport for every test would close the whole class; this change stays with the one file that opens the socket.

Checklist

  • This PR is focused and does not include secrets, temporary prompts, generated scratch files, or unrelated artifacts.
  • Relevant verification is recorded above, or skipped checks are explained.
  • User-facing strings, docs, and locales are updated where applicable. (No string changes.)

SettingsScene mounts useExternalAppAwareness, which calls the external sources
API. Outside Tauri that resolves to the WebSocket adapter, so the routing test
opened a socket to ws://localhost:8080/ws, and the failed connection left a
reconnect timer retrying and logging well past the end of the file. When one of
those logs lands in a worker whose rpc is already closing, the run fails with

  EnvironmentTeardownError: [vitest-worker]: Closing rpc while
  "onUserConsoleLog" was pending

attributed to this file even though every test in it passed. It only shows up
on a runner slow enough to let the lookup reach the transport before the file
finishes, which is why it reads as a flake.

Mock the hook, the way the file already mocks every panel it renders. Verified
by stubbing the WebSocket global in a copy of the file and draining macrotasks:
one socket to ws://localhost:8080/ws before, none after.

Ports b3eb18b to this branch, which carries the same scene and the same test.
@bobleer
bobleer merged commit d5747ea into GCWing:1.0.0-explore Aug 20, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant