From cc55d082c37e857a6f5e4a672b946a30d8456926 Mon Sep 17 00:00:00 2001 From: Yagiz Nizipli Date: Sat, 19 Nov 2022 15:13:08 -0500 Subject: [PATCH 1/2] lib: improve AbortController creation duration --- lib/internal/abort_controller.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/internal/abort_controller.js b/lib/internal/abort_controller.js index ae12099bf802d3..701b8da2da70ee 100644 --- a/lib/internal/abort_controller.js +++ b/lib/internal/abort_controller.js @@ -309,12 +309,13 @@ function abortSignal(signal, reason) { } class AbortController { - #signal = createAbortSignal(); + #signal; /** * @type {AbortSignal} */ get signal() { + this.#signal ??= createAbortSignal(); return this.#signal; } @@ -322,7 +323,7 @@ class AbortController { * @param {any} reason */ abort(reason = new DOMException('This operation was aborted', 'AbortError')) { - abortSignal(this.#signal, reason); + abortSignal(this.#signal ??= createAbortSignal(), reason); } [customInspectSymbol](depth, options) { From 34489fecc55d0ba301599b01d710958793d00662 Mon Sep 17 00:00:00 2001 From: Yagiz Nizipli Date: Sat, 19 Nov 2022 15:13:36 -0500 Subject: [PATCH 2/2] lib: improve transferable abort controller exec --- lib/internal/abort_controller.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/internal/abort_controller.js b/lib/internal/abort_controller.js index 701b8da2da70ee..7a4381ecd13cb3 100644 --- a/lib/internal/abort_controller.js +++ b/lib/internal/abort_controller.js @@ -334,7 +334,7 @@ class AbortController { static [kMakeTransferable]() { const controller = new AbortController(); - controller.#signal = transferableAbortSignal(controller.#signal); + controller.#signal = createAbortSignal({ transferable: true }); return controller; } }