Files
scriptc/docs
Chris Tate 1d8d19e634 Run stream events and callbacks in Node's AsyncLocalStorage contexts
Stream events and callbacks ran with no store. Node's streams run each
step in the context of the code that triggers it: a step deferred with
process.nextTick (resume, emitReadable, endReadable, afterWrite, the
destroy and finish steps) in the context that scheduled it, and other
events in the context of the push(), write(), end(), destroy() or pipe()
call that emits them. Native-backed streams run their events in the
context of their handle.

The runtime now captures the active context where it defers a stream
step and enters it around the step's dispatch:
- the stream tick queue keeps each tick's scheduling context;
- the runtime's own process.nextTick jobs (zlib completions, pipeline and
  finished steps, readline) run in the context they were queued in, as
  user ticks already did;
- fs read and write stream requests keep the context of the call that
  started them, so a stream's open, reads, writes and close follow its
  creation;
- zlib streams keep their creation context and run each engine step's
  completion in it.

In programs that use AsyncLocalStorage, stream.finished and
stream.pipeline callbacks are bound to the context of their call, like
the other completion callbacks. Programs that do not use
AsyncLocalStorage compile to the same IR.

child_process and http2 events are unchanged.

Corpus 7383 and 7384.
2026-10-22 17:05:08 -05:00
..
2026-07-22 18:08:04 -05:00
2026-10-02 00:58:25 -05:00
2026-10-02 00:58:25 -05:00
2026-07-22 18:08:04 -05:00
2026-07-22 18:08:04 -05:00