From bc6dee3e5b2cb7dbee45f9c90c5ba470bcafb3bc Mon Sep 17 00:00:00 2001 From: Nathanael BOT Date: Tue, 17 Mar 2026 00:56:38 +0100 Subject: [PATCH] doc: clarify AbortSignal abort listener guidance Signed-off-by: Nathanael BOT --- doc/api/globals.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/doc/api/globals.md b/doc/api/globals.md index 47340c897b4a36..5603de32b1a697 100644 --- a/doc/api/globals.md +++ b/doc/api/globals.md @@ -176,10 +176,11 @@ that the `abortSignal.aborted` attribute is `false` before adding an `'abort'` event listener. Any event listeners attached to the `AbortSignal` should use the -`{ once: true }` option (or, if using the `EventEmitter` APIs to attach a -listener, use the `once()` method) to ensure that the event listener is -removed as soon as the `'abort'` event is handled. Failure to do so may -result in memory leaks. +`{ once: true }` option (or remove the listener manually) to ensure that the +event listener is removed as soon as the `'abort'` event is handled. Failure +to do so may result in memory leaks. Event listeners should also be removed if +they are no longer needed (for example, if the operation is completed before +the signal is aborted). ### `abortSignal.aborted`