Skip to content

Commit 12bf9b8

Browse files
committed
lib: improve transferable abort controller exec
PR-URL: #45525 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
1 parent 29fa2da commit 12bf9b8

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

lib/internal/abort_controller.js

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -318,27 +318,21 @@ function validateAbortController(obj) {
318318
}
319319

320320
class AbortController {
321-
#signal;
322-
323-
constructor() {
324-
this[kSignal] = createAbortSignal();
325-
}
326-
327321
/**
328322
* @type {AbortSignal}
329323
*/
330324
get signal() {
331325
validateAbortController(this);
332-
this.#signal ??= createAbortSignal();
333-
return this.#signal;
326+
this[kSignal] ??= createAbortSignal();
327+
return this[kSignal];
334328
}
335329

336330
/**
337331
* @param {any} reason
338332
*/
339333
abort(reason = new DOMException('This operation was aborted', 'AbortError')) {
340334
validateAbortController(this);
341-
abortSignal(this.#signal ??= createAbortSignal(), reason);
335+
abortSignal(this[kSignal] ??= createAbortSignal(), reason);
342336
}
343337

344338
[customInspectSymbol](depth, options) {
@@ -349,7 +343,7 @@ class AbortController {
349343

350344
static [kMakeTransferable]() {
351345
const controller = new AbortController();
352-
controller[kSignal] = transferableAbortSignal(controller[kSignal]);
346+
controller[kSignal] = createAbortSignal({ transferable: true });
353347
return controller;
354348
}
355349
}

0 commit comments

Comments
 (0)