MCPcopy Create free account
hub / github.com/heygen-com/hyperframes / parseBrowserTimeoutMsArg

Function parseBrowserTimeoutMsArg

packages/cli/src/utils/renderArgs.ts:52–72  ·  view source on GitHub ↗
(raw: string | undefined)

Source from the content-addressed store, hash-verified

50 * callers can spread the result without clobbering the engine default.
51 */
52export function parseBrowserTimeoutMsArg(raw: string | undefined): BrowserTimeoutParseResult {
53 if (raw == null) return { ok: true, value: undefined };
54 const parsed = Number(raw);
55 if (!Number.isFinite(parsed)) {
56 return { ok: false, error: { kind: "not-a-number", raw } };
57 }
58 if (parsed <= 0) {
59 return { ok: false, error: { kind: "not-positive", raw } };
60 }
61 if (parsed > MAX_PAGE_NAVIGATION_TIMEOUT_SECONDS) {
62 return { ok: false, error: { kind: "too-large", raw } };
63 }
64 const ms = Math.round(parsed * 1000);
65 if (ms < MIN_PAGE_NAVIGATION_TIMEOUT_MS) {
66 // Sub-millisecond inputs (e.g. 0.0004 s) round to 0 ms, which
67 // Puppeteer treats as "no timeout" — the opposite of the user's
68 // intent. Reject explicitly.
69 return { ok: false, error: { kind: "too-small", raw } };
70 }
71 return { ok: true, value: ms };
72}
73
74function browserTimeoutErrorMessage(error: BrowserTimeoutParseError): {
75 title: string;

Callers 2

renderArgs.test.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected