You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would consider any output other than throwing an error a bug. For all body mixin methods, an error is thrown when consuming the body more than once. Currently the second iterator won't return anything which is also very confusing behavior.
So the stream spec was updated to include async iterators in whatwg/streams#980, which means that we can't override the async iterator implementation, or get rid of it completely.
I opened an issue on the spec repo for this at whatwg/fetch#1488 which seems like the more applicable place to post this.
Bug Description
Using
for await (const whatever of response.body) {...}
you can kinda-kinda not consume a body multiple times.Reproducible By
Expected Behavior
I would consider any output other than throwing an error a bug. For all body mixin methods, an error is thrown when consuming the body more than once. Currently the second iterator won't return anything which is also very confusing behavior.
I guess something along the lines of:
This will match browser behavior by causing an error to be thrown when using it in a for await loop like browsers.
Or it could be reimplemented to include a body used check and throw an error if its been consumed?
Logs & Screenshots
Environment
Additional context
Node implements an async iterator onto the web
ReadableStream
, unlike browsers.Run in repl/browser console:
This is where a ReadableStream is constructed:
undici/lib/core/util.js
Line 351 in 674875a
I didn't really know what to do with this one. Browsers (Firefox & chrome) throw an error but deno has the same "buggy"/confusing behavior as node.
The text was updated successfully, but these errors were encountered: