Skip to content

Conversation

@ronag
Copy link
Member

@ronagronag 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-botnodejs-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
@ronagronagforce-pushed the stream-error-cleanup branch 3 times, most recently from 757667b to 8cda582CompareDecember 8, 2019 09:52
@ronag

This comment has been minimized.

@ronagronagforce-pushed the stream-error-cleanup branch 3 times, most recently from b365b0e to dc03c53CompareDecember 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.
@ronagronagforce-pushed the stream-error-cleanup branch from dc03c53 to 20a2a29CompareDecember 8, 2019 10:14
@ronag
Copy link
MemberAuthor

ronag commented Dec 8, 2019

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

@ronagronag changed the title stream: error state cleanupstream: error state timingDec 8, 2019
@TrottTrott 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

@nodejs/streams

Copy link
Member

@mcollinamcollina 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
MemberAuthor

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

No, not really.

@ronagronag mentioned this pull request Dec 12, 2019
@addaleaxaddaleax 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
MemberAuthor

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 <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
@BridgeAR
Copy link
Member

Landed in 67ed526 🎉

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author readyPRs that have at least one approval, no pending requests for changes, and a CI started.consoleIssues and PRs related to the console subsystem.semver-majorPRs that contain breaking changes and should be released in the next major version.streamIssues and PRs related to the stream subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants

@ronag@lpinca@mcollina@nodejs-github-bot@BridgeAR@addaleax@Trott