From 000315e75a20e82616a227702c98346f2b5e8b59 Mon Sep 17 00:00:00 2001 From: Levente Kurusa Date: Tue, 2 May 2023 02:14:13 +0200 Subject: [PATCH] fix(node/http): Request.setTimeout(0) should clear (#18949) Fixes: #18932 --- ext/node/polyfills/http.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ext/node/polyfills/http.ts b/ext/node/polyfills/http.ts index 1a585f74ce..6f78777428 100644 --- a/ext/node/polyfills/http.ts +++ b/ext/node/polyfills/http.ts @@ -351,6 +351,18 @@ class ClientRequest extends NodeWritable { } setTimeout(timeout: number, callback?: () => void) { + if (timeout == 0) { + // Node's underlying Socket implementation expects a 0 value to disable the + // existing timeout. + if (this.opts.timeout) { + clearTimeout(this.opts.timeout); + this.opts.timeout = undefined; + this.opts.signal = undefined; + } + + return; + } + const controller = new AbortController(); this.opts.signal = controller.signal;