-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
I'm honestly not sure if there is a problem in Node itself or in undici, but I'm seeing issues with the stream reader not releasing its lock properly when using `for await...of` to iterate over `response.body` in `sendResponse`. In any case, there may be a variety of `Response` implementations that people eventually want to use with this, and async iterators are hard to get right, so dropping down to the lower-level `getReader()` API for stream iteration seems like a prudent move.
- Loading branch information
Showing
4 changed files
with
15 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export async function* readStream(stream: ReadableStream<Uint8Array>): AsyncIterable<Uint8Array> { | ||
let reader = stream.getReader(); | ||
|
||
while (true) { | ||
const { done, value } = await reader.read(); | ||
if (done) break; | ||
yield value; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters