From b8090460a41e78e4c4bbbaabde94acae2f829b83 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Fri, 26 Jun 2026 16:07:11 +0000 Subject: [PATCH] Use schema guards for SSH readiness errors Co-authored-by: Julius Marminge --- apps/server/src/diagnostics/ProcessDiagnostics.ts | 4 +++- packages/ssh/src/tunnel.ts | 7 ++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/apps/server/src/diagnostics/ProcessDiagnostics.ts b/apps/server/src/diagnostics/ProcessDiagnostics.ts index 0011b0666b..0df17ae9e4 100644 --- a/apps/server/src/diagnostics/ProcessDiagnostics.ts +++ b/apps/server/src/diagnostics/ProcessDiagnostics.ts @@ -120,7 +120,9 @@ const ProcessDiagnosticsError = Schema.Union([ ]); type ProcessDiagnosticsError = typeof ProcessDiagnosticsError.Type; const isProcessDiagnosticsError = Schema.is(ProcessDiagnosticsError); -const decodeWindowsProcessRowsJson = Schema.decodeUnknownOption(Schema.fromJsonString(Schema.Unknown)); +const decodeWindowsProcessRowsJson = Schema.decodeUnknownOption( + Schema.fromJsonString(Schema.Unknown), +); function parsePositiveInt(value: string): number | null { const parsed = Number.parseInt(value, 10); diff --git a/packages/ssh/src/tunnel.ts b/packages/ssh/src/tunnel.ts index e8c2b92475..b5ad04c8e0 100644 --- a/packages/ssh/src/tunnel.ts +++ b/packages/ssh/src/tunnel.ts @@ -56,6 +56,7 @@ const SSH_READY_PROBE_TIMEOUT_MS = 1_000; const TUNNEL_SHUTDOWN_TIMEOUT_MS = 2_000; const REMOTE_READY_TIMEOUT_MS = 15_000; const REMOTE_REUSE_READY_TIMEOUT_MS = 2_000; +const isSshReadinessError = Schema.is(SshReadinessError); export interface RemoteT3RunnerOptions { readonly packageSpec?: string; @@ -233,7 +234,7 @@ function applyScriptPlaceholders( } export function describeReadinessCause(cause: unknown): unknown { - if (cause instanceof SshReadinessError) { + if (isSshReadinessError(cause)) { return { _tag: cause._tag, message: cause.message, @@ -922,7 +923,7 @@ export const waitForHttpReady = Effect.fn("ssh/tunnel.waitForHttpReady")(functio }); }).pipe( Effect.mapError((cause) => - cause instanceof SshReadinessError + isSshReadinessError(cause) ? cause : new SshReadinessError({ message: `Backend readiness probe failed at ${requestUrl}.`, @@ -943,7 +944,7 @@ export const waitForHttpReady = Effect.fn("ssh/tunnel.waitForHttpReady")(functio const result = yield* readinessClient.execute(HttpClientRequest.get(requestUrl)).pipe( Effect.mapError((cause) => - cause instanceof SshReadinessError + isSshReadinessError(cause) ? cause : new SshReadinessError({ message: `Backend readiness probe failed at ${requestUrl}.`,