Skip to content

Commit 7dbbf46

Browse files
fix(client-runtime): relay disconnects no longer show as thread errors
For relay connections the RPC session appends a network hint after "... disconnected." and "... could not establish a WebSocket connection.", so the end-anchored transport patterns missed them and the web chat view showed the disconnect as a thread error. The patterns now accept the sentence followed by whitespace or the end of the message. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
1 parent 8fb068c commit 7dbbf46

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { describe, expect, it } from "vite-plus/test";
22

3+
import { NETWORK_BLOCKING_HINT } from "./network.ts";
34
import { isTransportConnectionErrorMessage, sanitizeThreadErrorMessage } from "./transport.ts";
45

56
describe("isTransportConnectionErrorMessage", () => {
@@ -30,6 +31,16 @@ describe("isTransportConnectionErrorMessage", () => {
3031
expect(isTransportConnectionErrorMessage("ClientProtocolError: socket closed")).toBe(true);
3132
});
3233

34+
it("recognizes relay connection errors that carry the network hint", () => {
35+
for (const sentence of [
36+
"Relay environment disconnected.",
37+
"Relay environment could not establish a WebSocket connection.",
38+
]) {
39+
expect(isTransportConnectionErrorMessage(`${sentence} ${NETWORK_BLOCKING_HINT}`)).toBe(true);
40+
}
41+
expect(isTransportConnectionErrorMessage("The deploy was disconnected.yaml")).toBe(false);
42+
});
43+
3344
it("returns true for the T3 server WebSocket message", () => {
3445
expect(isTransportConnectionErrorMessage("Unable to connect to the T3 server WebSocket.")).toBe(
3546
true,

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@ const TRANSPORT_ERROR_PATTERNS = [
33
/\bSocketOpenError\b/i,
44
/\bSocket is not connected\b/i,
55
/Unable to connect to the T3 server WebSocket\./i,
6-
/\bis not connected\.$/i,
7-
/\bdisconnected\.$/i,
8-
/\bcould not establish a WebSocket connection\.$/i,
6+
// The RPC session can append a network hint after these sentences.
7+
/\b(?:is not connected|disconnected|could not establish a WebSocket connection)\.(?:\s|$)/i,
98
/\bClientProtocolError\b/i,
109
/\bRpcClientError\b/i,
1110
/\bping timeout\b/i,

0 commit comments

Comments
 (0)