1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-24 08:09:08 -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 committed by GitHub
parent 2ee55145c0
commit 000315e75a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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;