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: when value is already in buffer don't emit the next one #46813

Closed
wants to merge 6 commits into from

Conversation

rluvaton
Copy link
Member

@rluvaton rluvaton commented Feb 24, 2023

fix #46765

this is probably not the best solution, I would like to know if there is a better one.

The problem happens because when getting a second value and:

if (state.writing || state.corked || state.errored || !state.constructed)

returns false, so we write the second value with stream._write, and then clearBuffer is called which emits the rest


this PR is not ready to be merged, I did not set it as draft so I would be able to run tests

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/streams

@nodejs-github-bot nodejs-github-bot added the needs-ci PRs that need a full CI run. label Feb 24, 2023
@rluvaton rluvaton changed the title stream: when value is already in buffer don't emit the next one before the first stream: when value is already in buffer don't emit the next one Feb 24, 2023
@rluvaton rluvaton marked this pull request as ready for review February 24, 2023 10:49
@ronag
Copy link
Member

ronag commented Feb 24, 2023

I don't understand what this is trying to solve.

@rluvaton
Copy link
Member Author

The bug that this PR fixes

@@ -267,7 +267,7 @@ function constructNT(stream) {
} else if (err) {
errorOrDestroy(stream, err, true);
} else {
process.nextTick(emitConstructNT, stream);
emitConstructNT(stream);
Copy link
Member Author

Choose a reason for hiding this comment

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

This fixes the issue, @ronag I see you added this code, is there a purpose for the next tick?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm still trying to understand why it was fixed... race condition between who?

Copy link
Member

@ronag ronag left a comment

Choose a reason for hiding this comment

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

I think #46765 (comment) is the correct fix.

@rluvaton
Copy link
Member Author

Thanks @ronag. Closing my PR in favor of

@rluvaton rluvaton closed this Feb 25, 2023
@rluvaton rluvaton deleted the fix-46765 branch February 25, 2023 20:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-ci PRs that need a full CI run.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

stream.Transform changing order of items
3 participants