From 13aa1d70e905f1e1ec57d7eb57ad57d09d09deb2 Mon Sep 17 00:00:00 2001 From: Satya Rohith Date: Tue, 25 Jun 2024 17:02:40 +0530 Subject: fix(ext/node): ignore stream error during enqueue (#24243) --- ext/node/polyfills/http.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'ext') diff --git a/ext/node/polyfills/http.ts b/ext/node/polyfills/http.ts index f009d8a9e..6880f7cb8 100644 --- a/ext/node/polyfills/http.ts +++ b/ext/node/polyfills/http.ts @@ -1346,10 +1346,14 @@ export class ServerResponse extends NodeWritable { #socketOverride: any | null = null; static #enqueue(controller: ReadableStreamDefaultController, chunk: Chunk) { - if (typeof chunk === "string") { - controller.enqueue(ENCODER.encode(chunk)); - } else { - controller.enqueue(chunk); + try { + if (typeof chunk === "string") { + controller.enqueue(ENCODER.encode(chunk)); + } else { + controller.enqueue(chunk); + } + } catch (_) { + // The stream might have been closed. Ignore the error. } } -- cgit v1.2.3