Skip to content

stream: error state timing

Fix, clean up and simplify errored state.

  • errorEmitted should be set in the same tick as 'error' is emitted.
  • fix an edge case where errored was not set (if receiving error through _destroy)
  • errored should exist on Readable as well.
  • refactor destroy logic and make it easier to follow.

errorEmitted is currently set in a tick before 'error' is actually emitted which is a bit confusing (and inconsistent with other event has been emitted state, e.g. endEmitted). If we need to know the synchronous error state we should use errored.

There was a potential race in console (at least in theory). We want to swallow an error if it's about to be emitted. However, since errorEmitted was set to true in the tick before the error is actually emitted, the "swallow error" logic might not be applied if the timing is unfortunate.

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