mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 15:04:11 -05:00
fix(ext/node): ClientRequest.setTimeout(0) should remove listeners (#19240)
Co-authored-by: crowlkats <crowlkats@toaxl.com>
This commit is contained in:
parent
91ca9904b5
commit
9ddb39d4cd
1 changed files with 13 additions and 2 deletions
|
@ -349,7 +349,10 @@ class ClientRequest extends OutgoingMessage {
|
|||
this.socketPath = options!.socketPath;
|
||||
|
||||
if (options!.timeout !== undefined) {
|
||||
this.timeout = getTimerDuration(options.timeout, "timeout");
|
||||
const msecs = getTimerDuration(options.timeout, "timeout");
|
||||
const timeout = AbortSignal.timeout(msecs);
|
||||
timeout.onabort = () => this.emit("timeout");
|
||||
this._timeout = timeout;
|
||||
}
|
||||
|
||||
const signal = options!.signal;
|
||||
|
@ -414,7 +417,6 @@ class ClientRequest extends OutgoingMessage {
|
|||
this._ended = false;
|
||||
this.res = null;
|
||||
this.aborted = false;
|
||||
this.timeoutCb = null;
|
||||
this.upgradeOrConnect = false;
|
||||
this.parser = null;
|
||||
this.maxHeadersCount = null;
|
||||
|
@ -803,6 +805,15 @@ class ClientRequest extends OutgoingMessage {
|
|||
}
|
||||
|
||||
setTimeout(msecs: number, callback?: () => void) {
|
||||
if (msecs === 0) {
|
||||
if (this._timeout) {
|
||||
this.removeAllListeners("timeout");
|
||||
this._timeout.onabort = () => {};
|
||||
this._timeout = undefined;
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
if (this._ended || this._timeout) {
|
||||
return this;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue