mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-31 07:23:06 +08:00
Each call of a typed or untyped write, writev, transform, flush, final, construct or destroy option callback allocated a closure and a box holding the stream for its `callback` argument. The emitted thunks now take it from scr_stream_done_closure, which keeps the last one on the stream state and hands it out again while the stream holds its only reference and it has no own properties. A callback the user kept (stored, or passed to setImmediate or a promise) is not reused: the next call gets a new closure, and the kept one keeps its own stream reference. The cached closure holds the stream, so the stream drops it when it emits 'close' and traces it, which lets the cycle collector reclaim a stream dropped before it closes. RUNTIME_ABI_VERSION goes from 46 to 47 for scr_stream_done_closure.