/** * Chrome stderr crash monitor. * * GPU-process crashes (exit_code=133 / SIGTRAP) and Dawn CHECK failures never * reach page-level listeners; the only place they surface is the browser * process stderr this module classifies. */ export const CRASH_PATTERNS = /GPU process exited unexpectedly|exit_code=133|Check failed|FATAL|ContextResult::kTransientFailure|GPU state invalid/; export const FATAL_PATTERNS = /Check failed|FATAL/; export function createCrashWatch(start = Date.now()) { const events = []; const fatals = []; const feed = (line) => { if (!CRASH_PATTERNS.test(line)) return; const entry = { atMs: Date.now() - start, line: line.trim().slice(0, 240) }; events.push(entry); if (FATAL_PATTERNS.test(line)) fatals.push(entry); }; return { feed, events, fatals, get count() { return events.length; }, summary(limit = 20) { return { count: events.length, fatalCount: fatals.length, events: events.slice(0, limit) }; }, }; }