-
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
lib: allow byob reader for 'blob.stream()' #49713
Conversation
c.enqueue(new Uint8Array(buffer)); | ||
} | ||
// We keep reading until we either reach EOS, some error, or we | ||
// hit the flow rate of the stream (c.desiredSize). | ||
queueMicrotask(() => { | ||
if (c.desiredSize <= 0) { | ||
if (c.desiredSize < 0) { |
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.
Would draw attention of reviewers to this specific update it seems when we turn this into a ReadableByteStream the high water mark for bytestreams is 0 and for normal default streams is 1 hence we have to remove the equality here
see:
node/lib/internal/webstreams/readablestream.js
Lines 282 to 298 in 2ccfb23
if (`${type}` === 'bytes') { | |
if (size !== undefined) | |
throw new ERR_INVALID_ARG_VALUE.RangeError('strategy.size', size); | |
setupReadableByteStreamControllerFromSource( | |
this, | |
source, | |
extractHighWaterMark(highWaterMark, 0)); | |
} else { | |
if (type !== undefined) | |
throw new ERR_INVALID_ARG_VALUE('source.type', type); | |
setupReadableStreamDefaultControllerFromSource( | |
this, | |
source, | |
extractHighWaterMark(highWaterMark, 1), | |
extractSizeAlgorithm(size)); | |
} | |
} |
also each byte is considered to be an element in the case of byte streams and hence the desiredSize
can go below 0, I nonetheless asserted that the memory isnt overflowing in the existing tests but do take a look at them too if they look correct!
Thank You!
cc @nodejs/whatwg-stream |
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.
lgtm
Landed in 23a3410 |
Fixes: nodejs#47993 PR-URL: nodejs#49713 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Fixes: #47993