From cac0031a886066995bbd99075d61137821b0a32f Mon Sep 17 00:00:00 2001 From: Matteo Collina Date: Mon, 5 Feb 2024 18:04:00 +0100 Subject: [PATCH 1/5] fix pull-dont-push test on linux Signed-off-by: Matteo Collina --- test/fetch/pull-dont-push.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/test/fetch/pull-dont-push.js b/test/fetch/pull-dont-push.js index 24bad7c3923..c8782fff9cd 100644 --- a/test/fetch/pull-dont-push.js +++ b/test/fetch/pull-dont-push.js @@ -13,6 +13,7 @@ const { closeServerAsPromise } = require('../utils/node-http') test('Allow the usage of custom implementation of AbortController', async (t) => { let count = 0 let socket + const max = 1_000_000 const server = createServer((req, res) => { res.statusCode = 200 socket = res.socket @@ -21,7 +22,7 @@ test('Allow the usage of custom implementation of AbortController', async (t) => const stream = new Readable({ read () { this.push('a') - if (count++ > 1000000) { + if (count++ > max) { this.push(null) } } @@ -42,12 +43,14 @@ test('Allow the usage of custom implementation of AbortController', async (t) => // Some time is needed to fill the buffer await sleep(1000) - assert.strictEqual(socket.bytesWritten < 1024 * 1024, true) // 1 MB socket.destroy() + assert.strictEqual(count < max, true) // the stream should be closed before the max // consume the stream try { /* eslint-disable-next-line no-empty, no-unused-vars */ - for await (const chunk of res.body) {} + for await (const chunk of res.body) { + // process._rawDebug('chunk', chunk) + } } catch {} }) From cf8938db42259b90f143c51a30062e34bb1a36c8 Mon Sep 17 00:00:00 2001 From: Matteo Collina Date: Mon, 5 Feb 2024 18:04:26 +0100 Subject: [PATCH 2/5] fixup Signed-off-by: Matteo Collina --- test/fetch/pull-dont-push.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/fetch/pull-dont-push.js b/test/fetch/pull-dont-push.js index c8782fff9cd..3d4f80d3369 100644 --- a/test/fetch/pull-dont-push.js +++ b/test/fetch/pull-dont-push.js @@ -10,7 +10,7 @@ const { setTimeout: sleep } = require('timers/promises') const { closeServerAsPromise } = require('../utils/node-http') -test('Allow the usage of custom implementation of AbortController', async (t) => { +test('pull dont\'t push', async (t) => { let count = 0 let socket const max = 1_000_000 From 109a246b69ca5c19dfaafea15381b6385b0ca28f Mon Sep 17 00:00:00 2001 From: Matteo Collina Date: Mon, 5 Feb 2024 18:30:08 +0100 Subject: [PATCH 3/5] fixup Signed-off-by: Matteo Collina --- lib/fetch/index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/fetch/index.js b/lib/fetch/index.js index 6fe6844776e..144fb43022f 100644 --- a/lib/fetch/index.js +++ b/lib/fetch/index.js @@ -2021,7 +2021,9 @@ async function httpNetworkFetch ( // into stream. const buffer = new Uint8Array(bytes) if (buffer.byteLength) { - fetchParams.controller.controller.enqueue(buffer) + try { + fetchParams.controller.controller.enqueue(buffer) + } catch {} } // 8. If stream is errored, then terminate the ongoing fetch. From f473edc51364dcc19201a9e7b4093e9af5418b09 Mon Sep 17 00:00:00 2001 From: Matteo Collina Date: Mon, 5 Feb 2024 19:05:26 +0100 Subject: [PATCH 4/5] fixup Signed-off-by: Matteo Collina --- lib/fetch/index.js | 6 ++++++ test/wpt/runner/runner.mjs | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/lib/fetch/index.js b/lib/fetch/index.js index 144fb43022f..25224a2bf13 100644 --- a/lib/fetch/index.js +++ b/lib/fetch/index.js @@ -1097,9 +1097,15 @@ function fetchFinale (fetchParams, response) { // 4. Set internalResponse’s body’s stream to the result of internalResponse’s body’s stream piped through transformStream. internalResponse.body.stream.pipeThrough(transformStream) + let count = 0 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) { diff --git a/test/wpt/runner/runner.mjs b/test/wpt/runner/runner.mjs index 8af9eb7c68d..4673c8fc0be 100644 --- a/test/wpt/runner/runner.mjs +++ b/test/wpt/runner/runner.mjs @@ -254,6 +254,7 @@ export class WPTRunner extends EventEmitter { this.#stats.completed += 1 if (message.result.status === 1) { + let expectedFailure = false this.#stats.failed += 1 wptResult?.subtests.push({ @@ -265,6 +266,7 @@ export class WPTRunner extends EventEmitter { const name = normalizeName(message.result.name) if (file.flaky?.includes(name)) { + expectedFailure = true this.#stats.expectedFailures += 1 } else if (file.allowUnexpectedFailures || topLevel.allowUnexpectedFailures || file.fail?.includes(name)) { if (!file.allowUnexpectedFailures && !topLevel.allowUnexpectedFailures) { @@ -274,11 +276,15 @@ export class WPTRunner extends EventEmitter { } } + expectedFailure = true this.#stats.expectedFailures += 1 } else { process.exitCode = 1 console.error(message.result) } + if (!expectedFailure) { + process._rawDebug(`Failed test: ${path}`) + } } else { wptResult?.subtests.push({ status: 'PASS', From 122b2a28cad0379b1431512dd312a4b67c8c4c58 Mon Sep 17 00:00:00 2001 From: Matteo Collina Date: Mon, 5 Feb 2024 20:02:41 +0100 Subject: [PATCH 5/5] fixup Signed-off-by: Matteo Collina --- lib/fetch/index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/fetch/index.js b/lib/fetch/index.js index 25224a2bf13..5d3bf459b5b 100644 --- a/lib/fetch/index.js +++ b/lib/fetch/index.js @@ -1097,7 +1097,6 @@ function fetchFinale (fetchParams, response) { // 4. Set internalResponse’s body’s stream to the result of internalResponse’s body’s stream piped through transformStream. internalResponse.body.stream.pipeThrough(transformStream) - let count = 0 const byteStream = new ReadableStream({ readableStream: transformStream.readable, async pull (controller) {