(raw: string | undefined)
| 50 | * callers can spread the result without clobbering the engine default. |
| 51 | */ |
| 52 | export 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 | |
| 74 | function browserTimeoutErrorMessage(error: BrowserTimeoutParseError): { |
| 75 | title: string; |
no outgoing calls
no test coverage detected