Skip to content

Commit

Permalink
fix: fix the linux patch
Browse files Browse the repository at this point in the history
  • Loading branch information
Uzlopak committed Feb 6, 2024
1 parent cf4d90d commit a5c9a2e
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions lib/fetch/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand All @@ -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) {
return
}
}
Expand Down

0 comments on commit a5c9a2e

Please sign in to comment.