Skip to content

Commit b17c252

Browse files
t3dotggclaude
andcommitted
fix(client): unresponsive hosts no longer blame DNS or show a heartbeat as a slow request
- The slow-request toast skips server.reportClientActivity, a background report nobody waits on, and names the environment instead of its id. - A host that stops answering on an open connection now reads "<host> stopped responding for 15s. It may be overloaded, asleep, or off the network." The DNS/firewall hint stays for sockets that never open. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 72bdf1e commit b17c252

10 files changed

Lines changed: 58 additions & 23 deletions

File tree

‎apps/web/src/connection/platform.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -812,11 +812,11 @@ const layerEnvironmentOwnedDataCleanup = Layer.succeed(
812812
const layerRpcRequestObserver = Layer.succeed(
813813
EnvironmentRpcRequestObserver,
814814
EnvironmentRpcRequestObserver.of({
815-
observe: ({ environmentId, method }) =>
815+
observe: ({ environmentId, environmentLabel, method }) =>
816816
Effect.sync(() => {
817817
nextObservedRpcRequestId += 1;
818818
const requestId = `${environmentId}:${nextObservedRpcRequestId}`;
819-
trackRpcRequestSent(requestId, method, `${method} · ${environmentId}`);
819+
trackRpcRequestSent(requestId, method, `${method} · ${environmentLabel}`);
820820
return Effect.sync(() => {
821821
acknowledgeRpcRequest(requestId);
822822
});

‎apps/web/src/rpc/requestLatencyState.test.ts‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,15 @@ describe("requestLatencyState", () => {
5252
expect(getSlowRpcAckRequests()).toEqual([]);
5353
});
5454

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);
5860

59-
expect(getSlowRpcAckRequests()).toEqual([]);
60-
});
61+
expect(getSlowRpcAckRequests()).toEqual([]);
62+
},
63+
);
6164

6265
it.each(Object.values(WS_METHODS).filter((method) => method.startsWith("pullRequests.")))(
6366
"ignores pull request workspace request %s",

‎apps/web/src/rpc/requestLatencyState.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,12 @@ interface PendingRpcAckRequest {
3030
}
3131

3232
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+
]);
3439
const longRunningRpcAckMethods = new Set<string>([
3540
WS_METHODS.serverUpdateProvider,
3641
WS_METHODS.serverRefreshProviders,
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
export const NETWORK_BLOCKING_HINT =
22
"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‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ describe("isTransportConnectionErrorMessage", () => {
2323
it("recognizes connection errors emitted by the Effect RPC session", () => {
2424
expect(isTransportConnectionErrorMessage("Test environment disconnected.")).toBe(true);
2525
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);
2631
expect(
2732
isTransportConnectionErrorMessage(
2833
"Test environment could not establish a WebSocket connection.",

‎packages/client-runtime/src/errors/transport.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { NETWORK_BLOCKING_HINT } from "./network.ts";
1+
import { NETWORK_BLOCKING_HINT, UNRESPONSIVE_HOST_HINT } from "./network.ts";
22

33
const escapeRegExp = (text: string) => text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
44

@@ -13,6 +13,7 @@ const TRANSPORT_ERROR_PATTERNS = [
1313
`\\b(?:is not connected|disconnected|stopped responding|could not establish a WebSocket connection)\\.(?: ${escapeRegExp(NETWORK_BLOCKING_HINT)})?$`,
1414
"i",
1515
),
16+
new RegExp(`\\bstopped responding for \\d+s\\. ${escapeRegExp(UNRESPONSIVE_HOST_HINT)}$`, "i"),
1617
/\bClientProtocolError\b/i,
1718
/\bRpcClientError\b/i,
1819
/\bping timeout\b/i,

‎packages/client-runtime/src/rpc/client.test.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,9 @@ describe("environment RPC", () => {
137137
Effect.provideService(
138138
EnvironmentRpcRequestObserver,
139139
EnvironmentRpcRequestObserver.of({
140-
observe: ({ environmentId, method }) =>
140+
observe: ({ environmentId, environmentLabel, method }) =>
141141
Effect.sync(() => {
142-
observations.push(`start:${environmentId}:${method}`);
142+
observations.push(`start:${environmentId}:${environmentLabel}:${method}`);
143143
return Effect.sync(() => {
144144
observations.push(`finish:${environmentId}:${method}`);
145145
});
@@ -150,7 +150,7 @@ describe("environment RPC", () => {
150150

151151
expect(result).toEqual({ status: "available", version: "2026.6.0" });
152152
expect(observations).toEqual([
153-
`start:${TARGET.environmentId}:${WS_METHODS.cloudGetRelayClientStatus}`,
153+
`start:${TARGET.environmentId}:${TARGET.label}:${WS_METHODS.cloudGetRelayClientStatus}`,
154154
`finish:${TARGET.environmentId}:${WS_METHODS.cloudGetRelayClientStatus}`,
155155
]);
156156
}),

‎packages/client-runtime/src/rpc/client.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export class EnvironmentRpcUnavailableError extends Schema.TaggedError<Environme
3131

3232
export interface EnvironmentRpcRequestObservation {
3333
readonly environmentId: string;
34+
readonly environmentLabel: string;
3435
readonly method: string;
3536
}
3637

@@ -203,6 +204,7 @@ export const requestGuarded = Effect.fn("EnvironmentRpc.request")(function* <
203204
) => Effect.Effect<EnvironmentRpcSuccess<TTag>, EnvironmentRpcFailure<TTag>>;
204205
const completeObservation = yield* observer.observe({
205206
environmentId: supervisor.target.environmentId,
207+
environmentLabel: supervisor.target.label,
206208
method: tag,
207209
});
208210
return yield* method(input).pipe(Effect.ensuring(completeObservation));

‎packages/client-runtime/src/rpc/session.test.ts‎

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1084,10 +1084,22 @@ describe("RpcSessionFactory", () => {
10841084
}),
10851085
);
10861086

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 }) =>
10881092
Effect.gen(function* () {
10891093
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+
});
10911103
const readyFiber = yield* Effect.forkChild(session.ready);
10921104
const closedFiber = yield* Effect.forkChild(Effect.flip(session.closed));
10931105
const socket = yield* awaitSocket(sockets);
@@ -1109,7 +1121,8 @@ describe("RpcSessionFactory", () => {
11091121
expect(error).toBeInstanceOf(ConnectionTransientError);
11101122
expect(error).toMatchObject({
11111123
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.",
11131126
});
11141127
}).pipe(Effect.scoped, Effect.provide(TestClock.layer())),
11151128
);

‎packages/client-runtime/src/rpc/session.ts‎

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
import * as Cause from "effect/Cause";
88
import * as Context from "effect/Context";
99
import * as Deferred from "effect/Deferred";
10+
import * as Duration from "effect/Duration";
1011
import * as Effect from "effect/Effect";
1112
import * as Equal from "effect/Equal";
1213
import * as Exit from "effect/Exit";
@@ -25,7 +26,7 @@ import * as RpcSerialization from "effect/rpc/RpcSerialization";
2526
import * as Socket from "effect/socket/Socket";
2627

2728
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";
2930
import type {
3031
ConnectionAttemptError,
3132
ConnectionTransientError,
@@ -122,6 +123,7 @@ function serverConfigReplayEvents(
122123
}
123124

124125
const isSocketErrorReason = Schema.is(Socket.SocketErrorReason);
126+
const PING_TIMEOUT_SECONDS = Duration.toSeconds(PING_TIMEOUT);
125127

126128
function mapSessionRpcError(
127129
error: InitialConfigError | ProbeError | ServerConfigSubscriptionError,
@@ -189,13 +191,14 @@ export const make = Effect.fn("RpcSessionFactory.make")(function* (
189191
disconnected,
190192
new ConnectionTransientErrorClass({
191193
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.`,
199202
...socketFailureLocation(via),
200203
}),
201204
),

0 commit comments

Comments
 (0)