From 9a0d59d95df29202080cf40a6e0bda52ca7fa6a8 Mon Sep 17 00:00:00 2001 From: Marvin Hagemeister Date: Wed, 10 Jul 2024 12:01:08 +0200 Subject: fix(node/http): don't send destroyed requests (#24498) Make sure that already destroyed requests are not actually sent. This error was discovered in jsdom's test suite. --- ext/node/polyfills/http.ts | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'ext/node/polyfills') diff --git a/ext/node/polyfills/http.ts b/ext/node/polyfills/http.ts index 0ef245902..51d228d4e 100644 --- a/ext/node/polyfills/http.ts +++ b/ext/node/polyfills/http.ts @@ -765,6 +765,9 @@ class ClientRequest extends OutgoingMessage { // deno-lint-ignore no-explicit-any end(chunk?: any, encoding?: any, cb?: any): this { + // Do nothing if request is already destroyed. + if (this.destroyed) return this; + if (typeof chunk === "function") { cb = chunk; chunk = null; @@ -797,6 +800,8 @@ class ClientRequest extends OutgoingMessage { // } })(); + + return this; } abort() { -- cgit v1.2.3