Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions apps/server/src/provider/CodexProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import {
import { resolveSpawnCommand } from "@t3tools/shared/shell";
import { codexAppServerArgs, resolveCodexLaunchArgs } from "./codexLaunchArgs.ts";
import {
AUTH_PROBE_TIMEOUT_MS,
buildServerProvider,
COMPACT_SLASH_COMMAND,
type ServerProviderDraft,
Expand Down Expand Up @@ -63,6 +62,11 @@ type CodexRateLimitsProbe =
| { readonly failure: string };

const CODEX_APP_SERVER_PROBE_FORCE_KILL_AFTER = "2 seconds" as const;
// 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",
Expand Down Expand Up @@ -618,7 +622,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,
);

Expand Down
18 changes: 17 additions & 1 deletion apps/server/src/provider/ProviderRegistry.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,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);
Expand All @@ -587,7 +603,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);
Expand Down
Loading