Repository navigation
Description
The app keeps its connection to the server alive with a loop: try to connect, wait, try again.
The problem. If anything inside that loop fails in a way nobody planned for, the loop stops and never restarts. Nothing is logged. The app stays on "connecting", and pressing Retry does nothing, because there is no loop left to hear it.
Proof. A test on main makes the platform's network-status read throw once during a connection attempt. Twenty simulated minutes and one explicit retry later:
× keeps reconnecting after an unexpected error inside the loop
AssertionError: expected 'connecting' to be 'connected'
state: phase=connecting stage=preparing attempt=1 sessions=0
The thrown error's text appears nowhere in the test output.
How likely it is. We know of no real trigger today. Failures while connecting are already caught and retried. The gap is everything else the loop touches, such as the network-status read used in the test.
Why there is no recording. It needs an internal error we can't cause from the app.
What to do. Where the loop is started (yield* run().pipe(Effect.forkScoped) in supervisor.ts), catch an unexpected failure, log its cause, and start the loop again.
The failing test
it.effect("keeps reconnecting after an unexpected error inside the loop", () =>
Effect.gen(function* () {
const harness = yield* makeHarness({
prepare: (attempt) =>
attempt === 1
? Effect.sleep("5 seconds").pipe(Effect.as(PREPARED_CONNECTION))
: Effect.succeed(PREPARED_CONNECTION),
});
const reads = yield* Ref.make(0);
const flaky = Connectivity.Connectivity.of({
status: Ref.updateAndGet(reads, (count) => count + 1).pipe(
Effect.flatMap((count) =>
count === 1
? Effect.succeed("online" as const)
: Effect.die(new Error("platform connectivity threw")),
),
),
changes: Stream.never,
});
const supervisor = yield* EnvironmentSupervisor.make(TARGET_ENTRY, {
initiallyDesired: true,
}).pipe(
Effect.provideService(Connectivity.Connectivity, flaky),
Effect.provide(harness.dependencies),
);
yield* TestClock.adjust("10 minutes");
yield* supervisor.retryNow;
yield* TestClock.adjust("10 minutes");
const state = yield* SubscriptionRef.get(supervisor.state);
expect(state.phase).toBe("connected");
}).pipe(Effect.provide(TestClock.layer())),
);Add it to packages/client-runtime/src/connection/supervisor.test.ts.
Activity
[-]XState POC: a missing actor in provide() compiles and fails silently[/-][+]XState trial: forgetting to join a worker compiles, then fails silently[/+][-]XState trial: forgetting to join a worker compiles, then fails silently[/-][+]A crash inside the reconnect loop stops it for good, and nothing is logged[/+]viktorce commentedon Nov 19, 2026
Reproduced in the running app
The issue says there is no recording because the error can't be caused from the app. It can. Two scenarios now cause it in the web client on main
57db750b8f. Each injects one fault from the page and leaves everything after that to the app. The fix is #41.1. The issue's own example: the network-status read throws
The scenario opens a thread, closes the app's socket from the page, as a network drop would, and makes the next read of
navigator.onLinethrow once. No real browser throws there, so this is an injected fault.On main the reconnect loop dies on that read. The banner says "is reconnecting" and stays. Ten seconds later the scenario presses Retry now. Five seconds after that, nothing has changed, and the page has logged nothing about the error:
Main on the left, the fix on the right. The red ring is the press on Retry now:
network-status-before-after.mp4
A control run of the same scenario with no injected throw reconnected on main's supervisor. So the stuck state comes from the thrown read and not from the dropped socket.
The scenario
Save it as
scripts/scenarios/reconnect-survives-network-status-defect.e2e.ts. It is not part of #41, because no real browser throws fromnavigator.onLine.2. A route real code has: the config stream fails while interrupted
The issue says no real trigger is known. Reading the code found one.
rpc/session.tsfails a session'sclosedwith whatever cause ended the config subscription, unless that cause holds interruptions only. A cause that holds a failure and an interruption gets through, andexitUnlessInterruptedin the supervisor turns any cause holding an interruption into an interruption of the loop.The scenario opens a thread and hands the app one server frame that ends the config subscription with a typed failure and an interruption in the same cause. The frame is injected from the page. I found no way to make a real server send it.
On main the loop dies and the app shows no sign of it. There is no banner and no error. Five seconds later the scenario types a message and presses Enter, and the message stays in the composer:
Main on the left, the fix on the right:
real-route-before-after.mp4
This scenario is part of #41.
What this changes in the issue
viktorce commentedon Nov 19, 2026
Filed upstream as pingdotgg#39418. The fix, #41 here, is upstream as pingdotgg#39420.
viktorce commentedon Nov 20, 2026
Fixed upstream by pingdotgg#39420, merged as
38bac7091a. The upstream issue, pingdotgg#39418, closed with it. The three other background tasks are still open as #39.