fix(client-runtime): relay disconnects no longer show as thread errors (#15470)
Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
1 parent
bf5c146be9
commit
a92c43b80b
2 files changed
+25
-3
No files matched your search
@@ -1,5 +1,6 @@
|
||||
import { describe, expect, it } from "vite-plus/test";
|
||||
|
||||
import { NETWORK_BLOCKING_HINT } from "./network.ts";
|
||||
import { isTransportConnectionErrorMessage, sanitizeThreadErrorMessage } from "./transport.ts";
|
||||
|
||||
describe("isTransportConnectionErrorMessage", () => {
|
||||
@@ -30,6 +31,20 @@ describe("isTransportConnectionErrorMessage", () => {
|
||||
expect(isTransportConnectionErrorMessage("ClientProtocolError: socket closed")).toBe(true);
|
||||
});
|
||||
|
||||
it("recognizes relay connection errors that carry the network hint", () => {
|
||||
for (const sentence of [
|
||||
"Relay environment disconnected.",
|
||||
"Relay environment could not establish a WebSocket connection.",
|
||||
]) {
|
||||
expect(isTransportConnectionErrorMessage(`${sentence} ${NETWORK_BLOCKING_HINT}`)).toBe(true);
|
||||
}
|
||||
expect(
|
||||
isTransportConnectionErrorMessage(
|
||||
"Your ChatGPT connection expired or was disconnected. Sign in again.",
|
||||
),
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("returns true for the T3 server WebSocket message", () => {
|
||||
expect(isTransportConnectionErrorMessage("Unable to connect to the T3 server WebSocket.")).toBe(
|
||||
true,
|
||||
|
||||
@@ -1,11 +1,18 @@
|
||||
import { NETWORK_BLOCKING_HINT } from "./network.ts";
|
||||
|
||||
const escapeRegExp = (text: string) => text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
||||
|
||||
const TRANSPORT_ERROR_PATTERNS = [
|
||||
/\bSocketCloseError\b/i,
|
||||
/\bSocketOpenError\b/i,
|
||||
/\bSocket is not connected\b/i,
|
||||
/Unable to connect to the T3 server WebSocket\./i,
|
||||
/\bis not connected\.$/i,
|
||||
/\bdisconnected\.$/i,
|
||||
/\bcould not establish a WebSocket connection\.$/i,
|
||||
// The RPC session appends the network hint for relay connections. Any other
|
||||
// trailing text means a different error that the user should still see.
|
||||
new RegExp(
|
||||
`\\b(?:is not connected|disconnected|could not establish a WebSocket connection)\\.(?: ${escapeRegExp(NETWORK_BLOCKING_HINT)})?$`,
|
||||
"i",
|
||||
),
|
||||
/\bClientProtocolError\b/i,
|
||||
/\bRpcClientError\b/i,
|
||||
/\bping timeout\b/i,
|
||||
|
||||
Reference in new issue
Block a user