fix: parse codex migration timeout env strictly · openclaw/openclaw@929b3a4
steipete
·
2026-05-29
·
via Recent Commits to openclaw:main
File tree
extensions/codex/src/migration
| Original file line number | Diff line number | Diff line change |
|---|
@@ -14,6 +14,7 @@ import {
|
14 | 14 | withCachedMigrationConfigRuntime, |
15 | 15 | writeMigrationReport, |
16 | 16 | } from "openclaw/plugin-sdk/migration-runtime"; |
| 17 | +import { parseStrictNonNegativeInteger } from "openclaw/plugin-sdk/number-runtime"; |
17 | 18 | import type { |
18 | 19 | MigrationApplyResult, |
19 | 20 | MigrationItem, |
@@ -362,9 +363,13 @@ function hasOpenAiCuratedMarketplace(response: unknown): boolean {
|
362 | 363 | ); |
363 | 364 | } |
364 | 365 | |
365 | | -function targetCodexMarketplaceDiscoveryTimeoutMs(): number { |
366 | | -const configured = Number(process.env[TARGET_CODEX_MARKETPLACE_DISCOVERY_TIMEOUT_ENV]); |
367 | | -if (Number.isFinite(configured) && configured >= 0) { |
| 366 | +export function targetCodexMarketplaceDiscoveryTimeoutMs( |
| 367 | +env: NodeJS.ProcessEnv = process.env, |
| 368 | +): number { |
| 369 | +const configured = parseStrictNonNegativeInteger( |
| 370 | +env[TARGET_CODEX_MARKETPLACE_DISCOVERY_TIMEOUT_ENV], |
| 371 | +); |
| 372 | +if (configured !== undefined) { |
368 | 373 | return configured; |
369 | 374 | } |
370 | 375 | return TARGET_CODEX_MARKETPLACE_DISCOVERY_TIMEOUT_MS; |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -7,6 +7,7 @@ import { defaultCodexAppInventoryCache } from "../app-server/app-inventory-cache
|
7 | 7 | import { CODEX_PLUGINS_MARKETPLACE_NAME } from "../app-server/config.js"; |
8 | 8 | import { buildCodexPluginAppCacheKey } from "../app-server/plugin-app-cache-key.js"; |
9 | 9 | import type { CodexGetAccountResponse, v2 } from "../app-server/protocol.js"; |
| 10 | +import { targetCodexMarketplaceDiscoveryTimeoutMs } from "./apply.js"; |
10 | 11 | import { buildCodexMigrationProvider } from "./provider.js"; |
11 | 12 | |
12 | 13 | const appServerRequest = vi.hoisted(() => vi.fn()); |
@@ -174,6 +175,27 @@ afterEach(async () => {
|
174 | 175 | }); |
175 | 176 | |
176 | 177 | describe("buildCodexMigrationProvider", () => { |
| 178 | +it("parses target marketplace discovery timeout env strictly", () => { |
| 179 | +expect( |
| 180 | +targetCodexMarketplaceDiscoveryTimeoutMs({ |
| 181 | +OPENCLAW_CODEX_MIGRATION_PLUGIN_LIST_TIMEOUT_MS: "0", |
| 182 | +}), |
| 183 | +).toBe(0); |
| 184 | +expect( |
| 185 | +targetCodexMarketplaceDiscoveryTimeoutMs({ |
| 186 | +OPENCLAW_CODEX_MIGRATION_PLUGIN_LIST_TIMEOUT_MS: "250", |
| 187 | +}), |
| 188 | +).toBe(250); |
| 189 | + |
| 190 | +for (const value of ["0x10", "1e3", "2.5"]) { |
| 191 | +expect( |
| 192 | +targetCodexMarketplaceDiscoveryTimeoutMs({ |
| 193 | +OPENCLAW_CODEX_MIGRATION_PLUGIN_LIST_TIMEOUT_MS: value, |
| 194 | +}), |
| 195 | +).toBe(30_000); |
| 196 | +} |
| 197 | +}); |
| 198 | + |
177 | 199 | beforeEach(() => { |
178 | 200 | appServerRequest.mockRejectedValue(new Error("codex app-server unavailable")); |
179 | 201 | }); |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。