mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-02 08:35:07 +08:00
18 lines
661 B
TypeScript
18 lines
661 B
TypeScript
// Immediate unref semantics at loop exit: an unref'd immediate fires if
|
|
// something reffed still holds the loop through its check phase (FIFO
|
|
// with its reffed neighbors), but once ONLY unref'd immediates remain the
|
|
// loop exits and they never fire — Node's exact liveness rule, and the
|
|
// runtime releases the never-fired closure (the sanitizer lane audits
|
|
// that).
|
|
setImmediate(() => {
|
|
console.log("unrefd neighbor fires");
|
|
}).unref();
|
|
setImmediate(() => {
|
|
console.log("reffed fires");
|
|
// Queued for the NEXT turn with nothing reffed left: never fires.
|
|
setImmediate(() => {
|
|
console.log("never");
|
|
}).unref();
|
|
});
|
|
console.log("main done");
|