1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-28 16:20:57 -05:00

fix(node/http): Request.setTimeout(0) should clear (#18949)

Fixes: #18932
This commit is contained in:
Levente Kurusa 2023-05-02 02:14:13 +02:00
parent fae7643648
commit 348946aa5e
No known key found for this signature in database
GPG key ID: 9F72F3C05BA137C4

View file

@ -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;