Files
scriptc/tests/corpus/process-uncaught-loop.cjs
T
Chris Tate e24c8a14dc Preserve native class state and handle terminal process events
- Preserve fields, accessors, added properties, and cyclic references across untyped class boundaries.
- Support platform signal names and native exception handlers that resume queued work.
2026-09-29 09:07:31 -05:00

21 lines
908 B
JavaScript

let count = 0;
const late = (error) => console.log("late", error.message);
const removed = (error) => console.log("snapshot", error.message);
const handler = (error, origin) => {
console.log("handled", error.message, origin);
process.off("uncaughtException", removed);
if (count === 1) process.once("uncaughtException", late);
process.nextTick(() => console.log("tick", count));
};
process.on("uncaughtException", handler);
process.on("uncaughtException", removed);
process.once("uncaughtExceptionMonitor", (error, origin) => console.log("monitor", error.message, origin));
const interval = setInterval(() => {
count++;
if (count < 3) throw new Error("interval " + count);
clearInterval(interval);
process.off("uncaughtException", handler);
process.once("uncaughtException", (value, origin) => console.log("primitive", value, origin));
setImmediate(() => { throw "immediate"; });
}, 10);