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 6bfdfc2
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions lib/fetch/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1100,11 +1100,6 @@ function fetchFinale (fetchParams, response) {
const byteStream = new ReadableStream({
readableStream: transformStream.readable,
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) {
Expand All @@ -1117,6 +1112,8 @@ function fetchFinale (fetchParams, response) {

controller.enqueue(value)
}

reader.releaseLock()
},
queuingStrategy: new ByteLengthQueuingStrategy({ highWaterMark: 16384 }),
type: 'bytes'
Expand Down Expand Up @@ -1910,8 +1907,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 +2023,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 +2034,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 6bfdfc2

Please sign in to comment.