Skip to content

Commit 5aaf56c

Browse files
fix(connect): bound transport failure diagnostics
1 parent 582fca9 commit 5aaf56c

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

‎apps/server/src/cloud/relayResponse.test.ts‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { expect, it } from "@effect/vitest";
22
import * as Effect from "effect/Effect";
33
import { HttpClientRequest, HttpClientResponse } from "effect/unstable/http";
4+
import * as HttpClientError from "effect/unstable/http/HttpClientError";
45

56
import { filterRelayResponse, relayRequestError, shouldRetryCloudLink } from "./relayResponse.ts";
67

@@ -16,6 +17,25 @@ const response = (
1617
: Response.json(body, { status, ...(headers ? { headers } : {}) }),
1718
);
1819

20+
it("reports a transport failure category without exposing request or cause details", () => {
21+
const error = relayRequestError(
22+
new HttpClientError.HttpClientError({
23+
reason: new HttpClientError.TransportError({
24+
request: HttpClientRequest.post("https://relay.example.test/link?token=private-token"),
25+
description: "private transport details",
26+
cause: new Error("private cause details"),
27+
}),
28+
}),
29+
);
30+
31+
expect(error._tag).toBe("EnvironmentHttpInternalServerError");
32+
expect(error.message).toContain("TransportError");
33+
expect(error.message).toContain("network connection");
34+
expect(error.message).not.toContain("relay.example.test");
35+
expect(error.message).not.toContain("private");
36+
expect(shouldRetryCloudLink(error)).toBe(true);
37+
});
38+
1939
it.effect("reports the tunnel limit and relay trace instead of a generic 403", () =>
2040
Effect.gen(function* () {
2141
const error = yield* filterRelayResponse(

‎apps/server/src/cloud/relayResponse.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export function relayRequestError(cause: unknown) {
2525
return isRelayResponseError(cause)
2626
? cause
2727
: new EnvironmentHttpInternalServerError({
28-
message: `Could not complete the T3 Connect relay request. ${isHttpClientError(cause) ? cause.message : "The relay returned an unexpected response."} Check this machine's network connection and relay availability, then retry.`,
28+
message: `Could not complete the T3 Connect relay request. ${isHttpClientError(cause) ? `The relay request failed (${cause.reason._tag}).` : "The relay returned an unexpected response."} Check this machine's network connection and relay availability, then retry.`,
2929
});
3030
}
3131

0 commit comments

Comments
 (0)