TypeScript
fix(codex): a slow but healthy Codex no longer shows as Unavailable (#15945)
shivamcfafb4bb54d2
diff --git a/apps/server/src/provider/CodexProvider.ts b/apps/server/src/provider/CodexProvider.tsindex f15ad138ee9..f4f123dc1a2 100644--- a/apps/server/src/provider/CodexProvider.ts+++ b/apps/server/src/provider/CodexProvider.ts@@ -36,7 +36,6 @@ import {import { resolveSpawnCommand } from "@t3tools/shared/shell";import { codexAppServerArgs, resolveCodexLaunchArgs } from "./codexLaunchArgs.ts";import {- AUTH_PROBE_TIMEOUT_MS,buildServerProvider,COMPACT_SLASH_COMMAND,providerModelsFromSettings,@@ -71,6 +70,11 @@ const CODEX_APP_SERVER_PROBE_FORCE_KILL_AFTER = "2 seconds" as const;const CODEX_CATALOG_REFRESH_TIMEOUT = "3 seconds" as const;const CODEX_CATALOG_REFRESH_POLL = "100 millis" as const;const CODEX_CLIENT_NAME = "T3 Code";+// Codex's probe does a full handshake plus account, models, and skills requests, which can+// legitimately run past the shared 10s AUTH_PROBE_TIMEOUT_MS on a loaded or slow machine+// (most often reported on Windows). Give Codex its own longer budget instead of raising the+// timeout for every provider.+const CODEX_AUTH_PROBE_TIMEOUT_MS = 20_000;const CODEX_PRESENTATION = {displayName: "Codex",@@ -660,7 +664,7 @@ export const checkCodexProviderStatus = Effect.fn("checkCodexProviderStatus")(fu...(managedAuth ? { skipNativeUsage: true } : {}),}).pipe(Effect.scoped,- Effect.timeoutOption(Duration.millis(AUTH_PROBE_TIMEOUT_MS)),+ Effect.timeoutOption(Duration.millis(CODEX_AUTH_PROBE_TIMEOUT_MS)),Effect.result,);diff --git a/apps/server/src/provider/ProviderRegistry.test.ts b/apps/server/src/provider/ProviderRegistry.test.tsindex 082014a116b..6ce4f08d859 100644--- a/apps/server/src/provider/ProviderRegistry.test.ts+++ b/apps/server/src/provider/ProviderRegistry.test.ts@@ -588,6 +588,22 @@ it.layer(}),);+ it.effect(+ "does not time out a healthy probe slower than the shared 10s auth-probe timeout (#7513)",+ () =>+ Effect.gen(function* () {+ const statusFiber = yield* checkCodexProviderStatus(defaultCodexSettings, () =>+ Effect.sleep("15 seconds").pipe(Effect.as(makeCodexProbeSnapshot())),+ ).pipe(Effect.forkChild);++ yield* Effect.yieldNow;+ yield* TestClock.adjust("15 seconds");++ const status = yield* Fiber.join(statusFiber);+ assert.strictEqual(status.status, "ready");+ }),+ );+it.effect("closes the app-server probe scope when provider status times out", () =>Effect.gen(function* () {const killCalls = yield* Ref.make(0);@@ -597,7 +613,7 @@ it.layer();yield* Effect.yieldNow;- yield* TestClock.adjust("11 seconds");+ yield* TestClock.adjust("21 seconds");yield* Effect.yieldNow;const status = yield* Fiber.join(statusFiber);