fix(openai): cap codex oauth preflight timeout · openclaw/openclaw@347486a
steipete
·
2026-05-30
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +import { MAX_TIMER_TIMEOUT_MS } from "openclaw/plugin-sdk/number-runtime"; |
| 2 | +import { afterEach, describe, expect, it, vi } from "vitest"; |
| 3 | +import { testing } from "./openai-codex-oauth.runtime.js"; |
| 4 | + |
| 5 | +describe("OpenAI Codex OAuth runtime", () => { |
| 6 | +afterEach(() => { |
| 7 | +vi.restoreAllMocks(); |
| 8 | +}); |
| 9 | + |
| 10 | +it("caps oversized TLS preflight timeouts before creating an abort signal", async () => { |
| 11 | +const timeoutSpy = vi.spyOn(AbortSignal, "timeout"); |
| 12 | +const fetchImpl = vi.fn(async () => new Response(null, { status: 302 })); |
| 13 | + |
| 14 | +await expect( |
| 15 | +testing.runOpenAIOAuthTlsPreflight({ |
| 16 | +timeoutMs: Number.MAX_SAFE_INTEGER, |
| 17 | + fetchImpl, |
| 18 | +}), |
| 19 | +).resolves.toEqual({ ok: true }); |
| 20 | + |
| 21 | +expect(timeoutSpy).toHaveBeenCalledWith(MAX_TIMER_TIMEOUT_MS); |
| 22 | +expect(fetchImpl).toHaveBeenCalledTimes(1); |
| 23 | +}); |
| 24 | +}); |
| Original file line number | Diff line number | Diff line change |
|---|
|
1 | 1 | import path from "node:path"; |
2 | 2 | import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime"; |
| 3 | +import { resolveTimerTimeoutMs } from "openclaw/plugin-sdk/number-runtime"; |
3 | 4 | import type { ProviderAuthContext } from "openclaw/plugin-sdk/plugin-entry"; |
4 | 5 | import { ensureGlobalUndiciEnvProxyDispatcher } from "openclaw/plugin-sdk/runtime-env"; |
5 | 6 | import { formatCliCommand } from "openclaw/plugin-sdk/setup-tools"; |
@@ -90,7 +91,7 @@ async function runOpenAIOAuthTlsPreflight(options?: {
|
90 | 91 | timeoutMs?: number; |
91 | 92 | fetchImpl?: typeof fetch; |
92 | 93 | }): Promise<OpenAIOAuthTlsPreflightResult> { |
93 | | -const timeoutMs = options?.timeoutMs ?? 5000; |
| 94 | +const timeoutMs = resolveTimerTimeoutMs(options?.timeoutMs, 5000); |
94 | 95 | const fetchImpl = options?.fetchImpl ?? fetch; |
95 | 96 | try { |
96 | 97 | await fetchImpl(openAIAuthProbeUrl, { |
@@ -110,6 +111,9 @@ async function runOpenAIOAuthTlsPreflight(options?: {
|
110 | 111 | } |
111 | 112 | } |
112 | 113 | |
| 114 | +export const testing = { runOpenAIOAuthTlsPreflight }; |
| 115 | +export { testing as __testing }; |
| 116 | + |
113 | 117 | function formatOpenAIOAuthTlsPreflightFix( |
114 | 118 | result: Exclude<OpenAIOAuthTlsPreflightResult, { ok: true }>, |
115 | 119 | ): string { |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。