fix(remote): stop CI teardown reporting itself as a broken connection#182
Open
veksen wants to merge 1 commit into
Open
fix(remote): stop CI teardown reporting itself as a broken connection#182veksen wants to merge 1 commit into
veksen wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Query Doctor Analysis
3 queries analyzed
0 regressed · 0 improved · 0 new · 0 removed
2 pre-existing issues
SELECT "guests"."id", "guests"."session_id", "guests"."username", "guests"."avatar_path", "guests"."color", "guests"."side", "guests"."audio_recording_path", "guests"."audio_recording_public", "gue...
indexassets(event_id, inserted_at desc)
cost 31,003,449 → 1,498 (100% reduction)SELECT * FROM guest_ip_addresses WHERE ip_address = '127.0.0.1';
indexguest_ip_addresses(ip_address)
cost 154,402 → 8 (100% reduction)
Using assumed statistics (10000000 rows/table). For better results, sync production stats.
More detail → get_ci_run({ runId: "019f6d3a-5668-7841-8383-6d80dc1c0eb4" }) · view run · docs
At the end of a CI run, disposing the RPC stub makes capnweb fire onRpcBroken with "RPC session was shut down by disposing the main stub". Because dispose() never set the broken flag, that event flowed through triggerBroken into runInCI's onBroken and logged "API connection broken during CI run" right next to the verdict, reading as if the run was cut off. The run had actually completed normally (Site #3580). Set broken = true at the top of dispose() so an intentional teardown makes triggerBroken a no-op. connectWithReconnect is unaffected: its onBroken calls dispose() after the fact, and triggerBroken already guards on broken. Covered by an integration test that drives ApiClient.connect over an in-process WebSocket relay: an intentional dispose stays silent, while a real transport drop still reports the broken connection. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
veksen
force-pushed
the
fix-ci-teardown-broken-log
branch
from
July 16, 2026 23:18
891c341 to
fcc7258
Compare
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.
Goal
Make CI run logs trustworthy: the final lines should reflect the verdict, not a scary false warning. Fixes Query-Doctor/Site#3580.
What
Before: every CI run that reached teardown logged
[main] API connection broken during CI run: Error: RPC session was shut down by disposing the main stubright next to the verdict, reading as if the run was cut off mid-flight. After: an intentional teardown logs nothing; a genuine mid-run transport break still logs the broken-connection warning.The run in the issue had completed normally — ingest succeeded, the baseline was fetched, and the exit 1 came from a correct verdict (2 untriaged regressions). The connection was never broken; the message fired during our own teardown.
How
connect()insrc/remote/api-client.tswiresonRpcBroken → triggerBroken → onBroken.triggerBrokenguards on abrokenflag, butdispose()disposed the stub without ever setting it. Disposing the main stub makes capnweb fireonRpcBroken, so the intentional teardown reported itself as broken.Fix: set
broken = trueat the top ofdispose(), before disposing the stubs, sotriggerBrokenbecomes a no-op for an intentional teardown.connectWithReconnectis unaffected — itsonBrokencallsdispose()after the fact, andtriggerBrokenalready returns early whenbrokenis set.Read
src/remote/api-client.tsfirst (the one-line guard + comment), then the test.Tests
New
src/remote/api-client.test.tsdrivesApiClient.connectend-to-end over an in-processwsrelay that answers the real auth handshake — the only setup where capnweb actually firesonRpcBrokenon dispose (an in-memory MessagePort session does not reproduce it). Two cases:dispose()does not callonBroken;onBroken.Confirmed the dispose test fails without the guard and passes with it. Full suite green (285 passed),
tsc --noEmitclean, build clean.🤖 Generated with Claude Code