-
Notifications
You must be signed in to change notification settings - Fork 549
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
fix: fix the linux patch #2703
Merged
Merged
fix: fix the linux patch #2703
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1099,16 +1099,12 @@ function fetchFinale (fetchParams, response) { | |
|
||
const byteStream = new ReadableStream({ | ||
readableStream: transformStream.readable, | ||
async start () { | ||
this._bodyReader = this.readableStream.getReader() | ||
}, | ||
async pull (controller) { | ||
// TODO(mcollina): removen this block, not sure why pull() is called twice | ||
if (this.readableStream.locked) { | ||
return | ||
} | ||
|
||
const reader = this.readableStream.getReader() | ||
|
||
while (controller.desiredSize >= 0) { | ||
const { done, value } = await reader.read() | ||
const { done, value } = await this._bodyReader.read() | ||
|
||
if (done) { | ||
queueMicrotask(() => readableStreamClose(controller)) | ||
|
@@ -1910,8 +1906,8 @@ async function httpNetworkFetch ( | |
|
||
// 11. Let pullAlgorithm be an action that resumes the ongoing fetch | ||
// if it is suspended. | ||
const pullAlgorithm = () => { | ||
fetchParams.controller.resume() | ||
const pullAlgorithm = async () => { | ||
await fetchParams.controller.resume() | ||
} | ||
|
||
// 12. Let cancelAlgorithm be an algorithm that aborts fetchParams’s | ||
|
@@ -2026,9 +2022,7 @@ async function httpNetworkFetch ( | |
// into stream. | ||
const buffer = new Uint8Array(bytes) | ||
if (buffer.byteLength) { | ||
try { | ||
fetchParams.controller.controller.enqueue(buffer) | ||
} catch {} | ||
fetchParams.controller.controller.enqueue(buffer) | ||
} | ||
|
||
// 8. If stream is errored, then terminate the ongoing fetch. | ||
|
@@ -2039,7 +2033,7 @@ async function httpNetworkFetch ( | |
|
||
// 9. If stream doesn’t need more data ask the user agent to suspend | ||
// the ongoing fetch. | ||
if (!fetchParams.controller.controller.desiredSize) { | ||
if (fetchParams.controller.controller.desiredSize <= 0) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. According to MDN desiredSize can go negative if the stream is oversaturized. !(-1) is false. And if desiredSize is 0, then we know we can not push data, anyway. 0 would actually mean, that the stream is closed. So is my change correct? |
||
return | ||
} | ||
} | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
While debugging I realized that we call pullAlgorithm with an await but as pullAlgorithm is not an async function it basically "decouples" the promise logic and the await is pointless.
undici/lib/fetch/index.js
Line 1941 in cf4d90d
So with this change the await pullAlgorithm will actually have something to await.