@devries-cameron20 / t3code-1 / commits / 45ad8d9f00
Fork 0

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

fix(client): a frozen host no longer shows a heartbeat as slow or blames your DNS (#22212)

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

Theo Browne committed Oct 20, 2026 at 02:08 UTC 45ad8d9f0077e3dd6cd82a50df239bd8e18e0f7f
10 files changed +58 -23
apps/web/src/connection/platform.ts
+2 -2
@@ -812,11 +812,11 @@ const layerEnvironmentOwnedDataCleanup = Layer.succeed(
812 const layerRpcRequestObserver = Layer.succeed(
813 EnvironmentRpcRequestObserver,
814 EnvironmentRpcRequestObserver.of({
815 - observe: ({ environmentId, method }) =>
815 + observe: ({ environmentId, environmentLabel, method }) =>
816 Effect.sync(() => {
817 nextObservedRpcRequestId += 1;
818 const requestId = `${environmentId}:${nextObservedRpcRequestId}`;
819 - trackRpcRequestSent(requestId, method, `${method} · ${environmentId}`);
819 + trackRpcRequestSent(requestId, method, `${method} · ${environmentLabel}`);
820 return Effect.sync(() => {
821 acknowledgeRpcRequest(requestId);
822 });
apps/web/src/rpc/requestLatencyState.test.ts
+8 -5
@@ -52,12 +52,15 @@ describe("requestLatencyState", () => {
52 expect(getSlowRpcAckRequests()).toEqual([]);
53 });
54
55 - it("ignores usage summary requests", () => {
56 - trackRpcRequestSent("1", WS_METHODS.serverGetUsageSummary);
57 - vi.advanceTimersByTime(SLOW_RPC_ACK_THRESHOLD_MS * 2);
55 + it.each([WS_METHODS.serverGetUsageSummary, WS_METHODS.serverReportClientActivity])(
56 + "ignores background request %s",
57 + (method) => {
58 + trackRpcRequestSent("1", method);
59 + vi.advanceTimersByTime(SLOW_RPC_ACK_THRESHOLD_MS * 2);
60
59 - expect(getSlowRpcAckRequests()).toEqual([]);
60 - });
61 + expect(getSlowRpcAckRequests()).toEqual([]);
62 + },
63 + );
64
65 it.each(Object.values(WS_METHODS).filter((method) => method.startsWith("pullRequests.")))(
66 "ignores pull request workspace request %s",
apps/web/src/rpc/requestLatencyState.ts
+6 -1
@@ -30,7 +30,12 @@ interface PendingRpcAckRequest {
30 }
31
32 const pendingRpcAckRequests = new Map<string, PendingRpcAckRequest>();
33 -const untrackedRpcAckMethods = new Set<string>([WS_METHODS.serverGetUsageSummary]);
33 +// Background reports nobody waits on. A busy host delays them first, and warning
34 +// about a request the user never made does not say what is wrong.
35 +const untrackedRpcAckMethods = new Set<string>([
36 + WS_METHODS.serverGetUsageSummary,
37 + WS_METHODS.serverReportClientActivity,
38 +]);
39 const longRunningRpcAckMethods = new Set<string>([
40 WS_METHODS.serverUpdateProvider,
41 WS_METHODS.serverRefreshProviders,
packages/client-runtime/src/errors/network.ts
+3
@@ -1,2 +1,5 @@
1 export const NETWORK_BLOCKING_HINT =
2 "Your DNS or firewall may be blocking T3 Connect. Try another network, such as a different Wi-Fi or mobile data.";
3 +
4 +/** For a host that stopped answering on an open connection, so the network path was already working. */
5 +export const UNRESPONSIVE_HOST_HINT = "It may be overloaded, asleep, or off the network.";
packages/client-runtime/src/errors/transport.test.ts
+5
@@ -23,6 +23,11 @@ describe("isTransportConnectionErrorMessage", () => {
23 it("recognizes connection errors emitted by the Effect RPC session", () => {
24 expect(isTransportConnectionErrorMessage("Test environment disconnected.")).toBe(true);
25 expect(isTransportConnectionErrorMessage("Test environment stopped responding.")).toBe(true);
26 + expect(
27 + isTransportConnectionErrorMessage(
28 + "Test environment stopped responding for 15s. It may be overloaded, asleep, or off the network.",
29 + ),
30 + ).toBe(true);
31 expect(
32 isTransportConnectionErrorMessage(
33 "Test environment could not establish a WebSocket connection.",
packages/client-runtime/src/errors/transport.ts
+2 -1
@@ -1,4 +1,4 @@
1 -import { NETWORK_BLOCKING_HINT } from "./network.ts";
1 +import { NETWORK_BLOCKING_HINT, UNRESPONSIVE_HOST_HINT } from "./network.ts";
2
3 const escapeRegExp = (text: string) => text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
4
@@ -13,6 +13,7 @@ const TRANSPORT_ERROR_PATTERNS = [
13 `\\b(?:is not connected|disconnected|stopped responding|could not establish a WebSocket connection)\\.(?: ${escapeRegExp(NETWORK_BLOCKING_HINT)})?$`,
14 "i",
15 ),
16 + new RegExp(`\\bstopped responding for \\d+s\\. ${escapeRegExp(UNRESPONSIVE_HOST_HINT)}$`, "i"),
17 /\bClientProtocolError\b/i,
18 /\bRpcClientError\b/i,
19 /\bping timeout\b/i,
packages/client-runtime/src/rpc/client.test.ts
+3 -3
@@ -137,9 +137,9 @@ describe("environment RPC", () => {
137 Effect.provideService(
138 EnvironmentRpcRequestObserver,
139 EnvironmentRpcRequestObserver.of({
140 - observe: ({ environmentId, method }) =>
140 + observe: ({ environmentId, environmentLabel, method }) =>
141 Effect.sync(() => {
142 - observations.push(`start:${environmentId}:${method}`);
142 + observations.push(`start:${environmentId}:${environmentLabel}:${method}`);
143 return Effect.sync(() => {
144 observations.push(`finish:${environmentId}:${method}`);
145 });
@@ -150,7 +150,7 @@ describe("environment RPC", () => {
150
151 expect(result).toEqual({ status: "available", version: "2026.6.0" });
152 expect(observations).toEqual([
153 - `start:${TARGET.environmentId}:${WS_METHODS.cloudGetRelayClientStatus}`,
153 + `start:${TARGET.environmentId}:${TARGET.label}:${WS_METHODS.cloudGetRelayClientStatus}`,
154 `finish:${TARGET.environmentId}:${WS_METHODS.cloudGetRelayClientStatus}`,
155 ]);
156 }),
packages/client-runtime/src/rpc/client.ts
+2
@@ -31,6 +31,7 @@ export class EnvironmentRpcUnavailableError extends Schema.TaggedError<Environme
31
32 export interface EnvironmentRpcRequestObservation {
33 readonly environmentId: string;
34 + readonly environmentLabel: string;
35 readonly method: string;
36 }
37
@@ -203,6 +204,7 @@ export const requestGuarded = Effect.fn("EnvironmentRpc.request")(function* <
204 ) => Effect.Effect<EnvironmentRpcSuccess<TTag>, EnvironmentRpcFailure<TTag>>;
205 const completeObservation = yield* observer.observe({
206 environmentId: supervisor.target.environmentId,
207 + environmentLabel: supervisor.target.label,
208 method: tag,
209 });
210 return yield* method(input).pipe(Effect.ensuring(completeObservation));
packages/client-runtime/src/rpc/session.test.ts
+16 -3
@@ -1084,10 +1084,22 @@ describe("RpcSessionFactory", () => {
1084 }),
1085 );
1086
1087 - it.effect("closes the session after 15 seconds without a frame from the server", () =>
1087 + // Over T3 Connect too: the socket opened, so blaming DNS or a firewall misleads.
1088 + it.effect.each([
1089 + { relay: false, label: "direct" },
1090 + { relay: true, label: "relay" },
1091 + ])("closes the $label session after 15 seconds without a frame from the server", ({ relay }) =>
1092 Effect.gen(function* () {
1093 const { factory, sockets } = yield* makeFactory();
1090 - const session = yield* factory.connect(PREPARED);
1094 + const session = yield* factory.connect({
1095 + ...PREPARED,
1096 + target: relay
1097 + ? new RelayConnectionTarget({
1098 + environmentId: TARGET.environmentId,
1099 + label: TARGET.label,
1100 + })
1101 + : TARGET,
1102 + });
1103 const readyFiber = yield* Effect.forkChild(session.ready);
1104 const closedFiber = yield* Effect.forkChild(Effect.flip(session.closed));
1105 const socket = yield* awaitSocket(sockets);
@@ -1109,7 +1121,8 @@ describe("RpcSessionFactory", () => {
1121 expect(error).toBeInstanceOf(ConnectionTransientError);
1122 expect(error).toMatchObject({
1123 reason: "transport",
1112 - detail: "Test environment stopped responding.",
1124 + detail:
1125 + "Test environment stopped responding for 15s. It may be overloaded, asleep, or off the network.",
1126 });
1127 }).pipe(Effect.scoped, Effect.provide(TestClock.layer())),
1128 );
packages/client-runtime/src/rpc/session.ts
+11 -8
@@ -7,6 +7,7 @@ import {
7 import * as Cause from "effect/Cause";
8 import * as Context from "effect/Context";
9 import * as Deferred from "effect/Deferred";
10 +import * as Duration from "effect/Duration";
11 import * as Effect from "effect/Effect";
12 import * as Equal from "effect/Equal";
13 import * as Exit from "effect/Exit";
@@ -25,7 +26,7 @@ import * as RpcSerialization from "effect/rpc/RpcSerialization";
26 import * as Socket from "effect/socket/Socket";
27
28 import { makeWsRpcProtocolClient, PING_TIMEOUT, type WsRpcProtocolClient } from "./protocol.ts";
28 -import { NETWORK_BLOCKING_HINT } from "../errors/network.ts";
29 +import { NETWORK_BLOCKING_HINT, UNRESPONSIVE_HOST_HINT } from "../errors/network.ts";
30 import type {
31 ConnectionAttemptError,
32 ConnectionTransientError,
@@ -122,6 +123,7 @@ function serverConfigReplayEvents(
123 }
124
125 const isSocketErrorReason = Schema.is(Socket.SocketErrorReason);
126 +const PING_TIMEOUT_SECONDS = Duration.toSeconds(PING_TIMEOUT);
127
128 function mapSessionRpcError(
129 error: InitialConfigError | ProbeError | ServerConfigSubscriptionError,
@@ -189,13 +191,14 @@ export const make = Effect.fn("RpcSessionFactory.make")(function* (
191 disconnected,
192 new ConnectionTransientErrorClass({
193 reason: "transport",
192 - detail: `${
193 - !wasConnected
194 - ? `${connection.label} could not establish a WebSocket connection.`
195 - : timedOut
196 - ? `${connection.label} stopped responding.`
197 - : `${connection.label} disconnected.`
198 - }${networkHint}`,
194 + // The network hint only fits a socket that never opened. Once it
195 + // opened, the path worked, and a host that goes quiet is more
196 + // often overloaded or asleep than blocked.
197 + detail: !wasConnected
198 + ? `${connection.label} could not establish a WebSocket connection.${networkHint}`
199 + : timedOut
200 + ? `${connection.label} stopped responding for ${PING_TIMEOUT_SECONDS}s. ${UNRESPONSIVE_HOST_HINT}`
201 + : `${connection.label} disconnected.`,
202 ...socketFailureLocation(via),
203 }),
204 ),