Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stream: error state timing #30851

Closed
wants to merge 2 commits into from
Closed

Conversation

ronag
Copy link
Member

@ronag ronag commented Dec 8, 2019

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

@nodejs-github-bot nodejs-github-bot added console Issues and PRs related to the console subsystem. stream Issues and PRs related to the stream subsystem. labels Dec 8, 2019
@ronag ronag force-pushed the stream-error-cleanup branch 3 times, most recently from 757667b to 8cda582 Compare December 8, 2019 09:52
@ronag

This comment has been minimized.

@ronag ronag force-pushed the stream-error-cleanup branch 3 times, most recently from b365b0e to dc03c53 Compare December 8, 2019 10:12
Clean up end simplify errored state.

- errorEmitted should be set in the same tick as 'error' is emitted.
- errored should be set as soon as an error occurs.
- errored should exist on Readable as well.
- refactor destroy logic and make it easier to follow.
@ronag
Copy link
Member Author

ronag commented Dec 8, 2019

since this slightly changes timing it should probably be semver-major, even if it only applies to "internal" state.

@ronag ronag changed the title stream: error state cleanup stream: error state timing Dec 8, 2019
@Trott Trott added the semver-major PRs that contain breaking changes and should be released in the next major version. label Dec 8, 2019
@lpinca
Copy link
Member

lpinca commented Dec 9, 2019

@nodejs/streams

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we change the docs on any of this at all?

LGTM

@ronag
Copy link
Member Author

ronag commented Dec 9, 2019

Should we change the docs on any of this at all?

I don't think so. Did you have anything specific in mind? This mostly affects internal details and is how I think it is expected to work.

@mcollina
Copy link
Member

mcollina commented Dec 9, 2019

No, not really.

@addaleax addaleax added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Dec 14, 2019
@nodejs-github-bot
Copy link
Collaborator

nodejs-github-bot commented Dec 14, 2019

@ronag
Copy link
Member Author

ronag commented Dec 14, 2019

This need another TSC approval. Maybe @addaleax?

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

nodejs-github-bot commented Dec 15, 2019

BridgeAR pushed a commit that referenced this pull request Dec 15, 2019
Clean up end simplify errored state.

- errorEmitted should be set in the same tick as 'error' is emitted.
- errored should be set as soon as an error occurs.
- errored should exist on Readable as well.
- refactor destroy logic and make it easier to follow.

PR-URL: #30851
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
@BridgeAR
Copy link
Member

Landed in 67ed526 🎉

@BridgeAR BridgeAR closed this Dec 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. console Issues and PRs related to the console subsystem. semver-major PRs that contain breaking changes and should be released in the next major version. stream Issues and PRs related to the stream subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants