-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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: fix no data on partial decode #5226
Conversation
873406b
to
355b6c4
Compare
@@ -136,26 +136,31 @@ function readableAddChunk(stream, state, chunk, encoding, addToFront) { | |||
const e = new Error('stream.unshift() after end event'); | |||
stream.emit('error', e); | |||
} else { | |||
if (state.decoder && !addToFront && !encoding) | |||
var skipAdd; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would add a little comment here just to clarify why this is being introduced.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment added.
LGTM. Just a quick check, any perf regression? That |
Before this commit, it was possible to push a partial character to a readable stream where it was decoded as an empty string and then added to the internal buffer. This caused the stream to not emit any data, even when the rest of the character bytes were pushed separately, because of a non-zero length check of the first chunk in the internal buffer. Fixes: nodejs#5223
355b6c4
to
bbabbee
Compare
No idea about perf, there aren't any pure stream benchmarks at the moment. |
The net ones support passing both buffers and utf8 encoded things, you should be able to get some data (with some noise) |
IMHO there'd be too much variance in those benchmarks to measure any performance difference with a change like this. No matter what though, the bug needs to be fixed. |
Agreed, LGTM. |
LGTM |
Before this commit, it was possible to push a partial character to a readable stream where it was decoded as an empty string and then added to the internal buffer. This caused the stream to not emit any data, even when the rest of the character bytes were pushed separately, because of a non-zero length check of the first chunk in the internal buffer. Fixes: #5223 PR-URL: #5226 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Landed in 9221201. |
Before this commit, it was possible to push a partial character to a readable stream where it was decoded as an empty string and then added to the internal buffer. This caused the stream to not emit any data, even when the rest of the character bytes were pushed separately, because of a non-zero length check of the first chunk in the internal buffer. Fixes: #5223 PR-URL: #5226 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Before this commit, it was possible to push a partial character to a readable stream where it was decoded as an empty string and then added to the internal buffer. This caused the stream to not emit any data, even when the rest of the character bytes were pushed separately, because of a non-zero length check of the first chunk in the internal buffer. Fixes: #5223 PR-URL: #5226 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Before this commit, it was possible to push a partial character to a readable stream where it was decoded as an empty string and then added to the internal buffer. This caused the stream to not emit any data, even when the rest of the character bytes were pushed separately, because of a non-zero length check of the first chunk in the internal buffer. Fixes: #5223 PR-URL: #5226 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Before this commit, it was possible to push a partial character to a readable stream where it was decoded as an empty string and then added to the internal buffer. This caused the stream to not emit any data, even when the rest of the character bytes were pushed separately, because of a non-zero length check of the first chunk in the internal buffer. Fixes: #5223 PR-URL: #5226 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Before this commit, it was possible to push a partial character to a readable stream where it was decoded as an empty string and then added to the internal buffer. This caused the stream to not emit any data,
even when the rest of the character bytes were pushed separately, because of a non-zero length check of the first chunk in the internal buffer.
Fixes: #5223