Skip to content

Commit d6ae0e7

Browse files
t3dotggclaude
andcommitted
fix(connect): keep the relay health status out of failures with their own cause
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent d5934d3 commit d6ae0e7

3 files changed

Lines changed: 18 additions & 2 deletions

File tree

‎apps/web/src/components/settings/ConnectionDiagnosisDetails.tsx‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ export function useConnectionDiagnosis(environment: EnvironmentPresentation) {
4141
hostLabel: environment.label,
4242
state,
4343
via: relayOnly ? "relay" : "direct",
44-
relayStatus: Option.getOrNull(relayStatus ?? Option.none()),
44+
relayStatus: hasRelayRoute(environment.entry)
45+
? Option.getOrNull(relayStatus ?? Option.none())
46+
: null,
4547
clientVersion: APP_VERSION,
4648
serverVersion: environment.serverConfig?.environment.serverVersion,
4749
})

‎packages/client-runtime/src/connection/diagnosis.test.ts‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,19 @@ describe("presentConnectionDiagnosis", () => {
135135
expect(diagnosis?.headline).toBe("Mac mini's tunnel is offline");
136136
});
137137

138+
it("keeps the relay health status out of a failure that has its own cause", () => {
139+
const failure = mapRemoteEnvironmentError(
140+
new RemoteEnvironmentAuthFetchError({ message: "Failed to fetch", cause: new TypeError() }),
141+
);
142+
const diagnosis = presentConnectionDiagnosis({
143+
hostLabel: "Mac mini",
144+
state: backoff(failure),
145+
via: "direct",
146+
relayStatus: { status: "offline", endpointFailure: "tunnel_down", endpointStatus: 530 },
147+
});
148+
expect(diagnosis?.facts.map(([label]) => label)).not.toContain("HTTP status");
149+
});
150+
138151
it("has nothing to say when nothing failed", () => {
139152
expect(diagnose(AVAILABLE_CONNECTION_STATE)).toBeNull();
140153
});

‎packages/client-runtime/src/connection/diagnosis.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,8 @@ export function presentConnectionDiagnosis(
225225
result: index < failedIndex ? "ok" : index === failedIndex ? "failed" : "unchecked",
226226
}));
227227

228-
const httpStatus = failure?.httpStatus ?? input.relayStatus?.endpointStatus;
228+
// The relay health check only explains the state when no attempt has failed yet.
229+
const httpStatus = failure !== null ? failure.httpStatus : input.relayStatus?.endpointStatus;
229230
const facts: Array<readonly [string, string]> = [];
230231
const add = (label: string, value: string | number | null | undefined) => {
231232
if (value !== null && value !== undefined && value !== "") facts.push([label, String(value)]);

0 commit comments

Comments
 (0)