Skip to content

Commit bc6dee3

Browse files
author
Nathanael BOT
committed
doc: clarify AbortSignal abort listener guidance
Signed-off-by: Nathanael BOT <nathanaelbot@minidenathanael.home>
1 parent e86679d commit bc6dee3

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

doc/api/globals.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,10 +176,11 @@ that the `abortSignal.aborted` attribute is `false` before adding an `'abort'`
176176
event listener.
177177

178178
Any event listeners attached to the `AbortSignal` should use the
179-
`{ once: true }` option (or, if using the `EventEmitter` APIs to attach a
180-
listener, use the `once()` method) to ensure that the event listener is
181-
removed as soon as the `'abort'` event is handled. Failure to do so may
182-
result in memory leaks.
179+
`{ once: true }` option (or remove the listener manually) to ensure that the
180+
event listener is removed as soon as the `'abort'` event is handled. Failure
181+
to do so may result in memory leaks. Event listeners should also be removed if
182+
they are no longer needed (for example, if the operation is completed before
183+
the signal is aborted).
183184

184185
### `abortSignal.aborted`
185186

0 commit comments

Comments
 (0)