Playwright harness under scripts/browser: 127.0.0.1 server with the DEPLOY CSP, export and import baselines of the TypeScript engine under a 4 GiB RSS watchdog (not a guaranteed memory limit), O9 browser columns in inflate.browsers.json (26 rows agree with Node in all three engines). Results of 2026-10-18 committed; the O9 Node test no longer expects browser columns in inflate.json.
42 lines
1.2 KiB
JavaScript
42 lines
1.2 KiB
JavaScript
/** Promise helpers for races whose losers must never surface as unhandled. */
|
|
|
|
export const delay = (ms) => new Promise((done) => setTimeout(done, ms))
|
|
|
|
export const firstLine = (error) =>
|
|
String(error?.message ?? error).split('\n')[0]
|
|
|
|
/** `{ kind, value, at }` once `promise` resolves; rejected: kind 'error'. */
|
|
export function tagged(kind, promise) {
|
|
return promise.then(
|
|
(value) => ({ kind, value, at: performance.now() }),
|
|
(error) => ({
|
|
kind: 'error',
|
|
error: firstLine(error),
|
|
at: performance.now(),
|
|
}),
|
|
)
|
|
}
|
|
|
|
/** A race arm that never keeps the process alive on its own. */
|
|
export function timeoutAfter(ms) {
|
|
return new Promise((done) => {
|
|
setTimeout(
|
|
() => done({ kind: 'timeout', at: performance.now() }),
|
|
ms,
|
|
).unref()
|
|
})
|
|
}
|
|
|
|
/** Races `promise` with the watchdog: a killed browser ends the wait. */
|
|
export function untilStopped(session, promise) {
|
|
const stopped = session.watchdog.stopped.then((s) => ({
|
|
kind: s.type === 'ceiling' ? 'stopped_by_ceiling' : 'watchdog_failed',
|
|
error: s.error ?? null,
|
|
at: performance.now(),
|
|
}))
|
|
return Promise.race([promise, stopped])
|
|
}
|
|
|
|
export const isStop = (end) =>
|
|
end.kind === 'stopped_by_ceiling' || end.kind === 'watchdog_failed'
|