@devries-cameron20 / t3code-1 / commits / 35c7696790
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(web,mobile): time out client activity reports that never settle (#24362)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Sky Hong committed Nov 2, 2026 at 04:55 UTC 35c76967906b7971cfc43b87d7bb80ab50507115
3 files changed +33 -2
apps/mobile/src/connection/background-activity.ts
+4 -1
@@ -24,6 +24,8 @@ import {
24 } from "./background-activity-scopes";
25
26 const REPORT_INTERVAL_MS = 25_000;
27 +// Shorter than the interval, so a report that never settles cannot hold up the next one.
28 +const REPORT_TIMEOUT_MS = 15_000;
29 const LEASE_TTL_MS = 45_000;
30 const BASELINE_SCOPES: ReadonlyArray<BackgroundScope> = [{ type: "provider-status" }];
31
@@ -81,7 +83,8 @@ export const layerReporter = Layer.effectDiscard(
83 )
84 // Not `ignore`: tearing down an environment mid-request interrupts its report,
85 // and an interrupt leaking out here would end the reporting loop for good.
84 - .pipe(Effect.ignoreCause),
86 + // The timeout covers a live connection that never answers, which would stall it.
87 + .pipe(Effect.timeout(`${REPORT_TIMEOUT_MS} millis`), Effect.ignoreCause),
88 { concurrency: "unbounded", discard: true },
89 );
90 }).pipe(Effect.withSpan("mobile.backgroundActivity.report"));
apps/web/src/lib/backgroundActivityReporter.test.ts
+25
@@ -111,4 +111,29 @@ describe("layer", () => {
111 expect(calls).toBe(2);
112 }).pipe(Effect.scoped),
113 );
114 +
115 + it.effect("keeps reporting after a report never settles", () =>
116 + Effect.gen(function* () {
117 + const entries = yield* SubscriptionRef.make(
118 + new Map([[EnvironmentId.make("environment-reporter-test"), {}]]),
119 + );
120 + let calls = 0;
121 + const registry = EnvironmentRegistry.EnvironmentRegistry.of({
122 + entries,
123 + run: () => {
124 + calls += 1;
125 + return calls === 1 ? Effect.never : Effect.void;
126 + },
127 + } as unknown as EnvironmentRegistry.EnvironmentRegistry["Service"]);
128 +
129 + yield* Layer.build(
130 + layer.pipe(Layer.provide(Layer.succeed(EnvironmentRegistry.EnvironmentRegistry, registry))),
131 + );
132 + yield* TestClock.adjust("1 second");
133 + expect(calls).toBe(1);
134 +
135 + yield* TestClock.adjust("25 seconds");
136 + expect(calls).toBe(2);
137 + }).pipe(Effect.scoped),
138 + );
139 });
apps/web/src/lib/backgroundActivityReporter.ts
+4 -1
@@ -23,6 +23,8 @@ import { randomUUID } from "./utils";
23
24 const CLIENT_ID_STORAGE_KEY = "t3.backgroundActivity.clientId";
25 const REPORT_INTERVAL_MS = 25_000;
26 +// Shorter than the interval, so a report that never settles cannot hold up the next one.
27 +const REPORT_TIMEOUT_MS = 15_000;
28 const LEASE_TTL_MS = 45_000;
29 const RECENT_INTERACTION_WINDOW_MS = LEASE_TTL_MS;
30 const BASELINE_SCOPES: ReadonlyArray<BackgroundScope> = [{ type: "provider-status" }];
@@ -207,7 +209,8 @@ export const layer = Layer.effectDiscard(
209 )
210 // Not `ignore`: tearing down an environment mid-request interrupts its report,
211 // and an interrupt leaking out here would end the reporting loop for good.
210 - .pipe(Effect.ignoreCause),
212 + // The timeout covers a live connection that never answers, which would stall it.
213 + .pipe(Effect.timeout(`${REPORT_TIMEOUT_MS} millis`), Effect.ignoreCause),
214 { concurrency: "unbounded", discard: true },
215 );
216 }).pipe(Effect.withSpan("web.backgroundActivity.report"));