From 68320ff9f1e303eb3fbec46464e51e725026bf84 Mon Sep 17 00:00:00 2001 From: Robert Nagy Date: Mon, 24 Jun 2024 19:15:58 +0200 Subject: [PATCH] fixup --- lib/api/api-request.js | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/lib/api/api-request.js b/lib/api/api-request.js index e48925a4c84..d321db624c2 100644 --- a/lib/api/api-request.js +++ b/lib/api/api-request.js @@ -56,25 +56,20 @@ class RequestHandler extends AsyncResource { this.onInfo = onInfo || null this.throwOnError = throwOnError this.highWaterMark = highWaterMark - this.signal = signal this.reason = null this.removeAbortListener = null - if (this.signal?.aborted) { - this.reason = this.signal.reason ?? new RequestAbortedError() + if (signal?.aborted) { + this.reason = signal.reason ?? new RequestAbortedError() } else if (signal) { - this.removeAbortListener = util.addAbortListener(this.signal, () => { - this.reason = this.signal.reason ?? new RequestAbortedError() - } else { - this.removeAbortListener = util.addAbortListener(this.signal, () => { - this.reason = this.signal.reason ?? new RequestAbortedError() - if (this.res) { - util.destroy(this.res, this.reason) - } else if (this.abort) { - this.abort(this.reason) - } - }) - } + this.removeAbortListener = util.addAbortListener(signal, () => { + this.reason = signal.reason ?? new RequestAbortedError() + if (this.res) { + util.destroy(this.res, this.reason) + } else if (this.abort) { + this.abort(this.reason) + } + }) } }