Skip to content

stream: allow throwing from _read

_read is a sync api and should handle errors accordingly. Furthermore, userland does not have access to errorOrDestroy and will often implement error handling incorrectly or not at all.

_write, _writev, _final should never throw. However, if they do the error case should be predictable.

In order to maintain compatibility with SyncWriteStream a syncError option is added for Writable in order to allow errors to be thrown synchronously to the caller.

Furthermore, userland does not have access to errorOrDestroy and will often implement error handling incorrectly or not at all.

try/catch should be fast since V8 turbofan.

A follow up to this PR would be to fix an (existing) bug where destroy is not called on SyncWriteStream on error even though it is autoDestroy: true.

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