Skip to content

stream: make stream.destroy with callback API public

This makes the stream.destroy(err, callback) API public.

Additionally it makes some changes:

  • The callback is always (see TODO) invoked with the same behavior as eos
  • The callback is no longer immediately invoked if destroy has already been invoked (but not actually completed).
  • The error is assumed to be handled and uncaughException is suppressed.
  • The callback timing is the same regardless whether destroy has already been called or not. (see TODO)
  • The callback is always invoked asynchronously.
  • The callback used to be invoked before emitting 'error' and/or 'close'. (see TODO)

Also fixes a bug for fs streams where the callback to close(cb) could either be invoked synchronously or before the stream was actually closed. Likewise during errored destruction with implementations that use stream commons writeGeneric.

This is made possible by https://github.com/nodejs/node/pull/31509

This affects a non-public API which is used internally at the following locations:

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

Merge request reports

Loading