summaryrefslogtreecommitdiff
path: root/ext/node/polyfills/http.ts
diff options
context:
space:
mode:
authorMarvin Hagemeister <marvin@deno.com>2024-07-10 10:05:41 +0200
committerGitHub <noreply@github.com>2024-07-10 10:05:41 +0200
commit2a86edf0afd65af3020c8e6ad84e26d5a687e535 (patch)
treeed10043cbbd8d1e5f6ff147975a787f09f35b952 /ext/node/polyfills/http.ts
parent92d567d3562600b2b06791353eeccf8f1d5c4f0f (diff)
fix(node/http): don't error if request destroyed before send (#24497)
A request can be destroyed before it was even made in the Node http API. We errored on that. This issue was discovered in the JSDOM test suite.
Diffstat (limited to 'ext/node/polyfills/http.ts')
-rw-r--r--ext/node/polyfills/http.ts5
1 files changed, 4 insertions, 1 deletions
diff --git a/ext/node/polyfills/http.ts b/ext/node/polyfills/http.ts
index 3059da3a6..0ef245902 100644
--- a/ext/node/polyfills/http.ts
+++ b/ext/node/polyfills/http.ts
@@ -322,6 +322,7 @@ class ClientRequest extends OutgoingMessage {
insecureHTTPParser: boolean;
useChunkedEncodingByDefault: boolean;
path: string;
+ _req: { requestRid: number; cancelHandleRid: number | null } | undefined;
constructor(
input: string | URL,
@@ -819,7 +820,9 @@ class ClientRequest extends OutgoingMessage {
if (rid) {
core.tryClose(rid);
}
- if (this._req.cancelHandleRid !== null) {
+
+ // Request might be closed before we actually made it
+ if (this._req !== undefined && this._req.cancelHandleRid !== null) {
core.tryClose(this._req.cancelHandleRid);
}
// If we're aborting, we don't care about any more response data.