GeezerVison is showing github.com — doc: recommend checking abortSignal.aborted first · nodejs/node@cf4fa79
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: doc/api/globals.md +9-5Lines changed: 9 additions & 5 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -89,11 +89,15 @@ ac.abort(); |
89 | 89 | ``` |
90 | 90 |
|
91 | 91 | The `AbortController` with which the `AbortSignal` is associated will only |
92 | | -ever trigger the `'abort'` event once. Any event listeners attached to the |
93 | | -`AbortSignal` *should* use the `{ once: true }` option (or, if using the |
94 | | -`EventEmitter` APIs to attach a listener, use the `once()` method) to ensure |
95 | | -that the event listener is removed as soon as the `'abort'` event is handled. |
96 | | -Failure to do so may result in memory leaks. |
| 92 | +ever trigger the `'abort'` event once. We recommended that code check |
| 93 | +that the `abortSignal.aborted` attribute is `false` before adding an `'abort'` |
| 94 | +event listener. |
| 95 | + |
| 96 | +Any event listeners attached to the `AbortSignal` should use the |
| 97 | +`{ once: true }` option (or, if using the `EventEmitter` APIs to attach a |
| 98 | +listener, use the `once()` method) to ensure that the event listener is |
| 99 | +removed as soon as the `'abort'` event is handled. Failure to do so may |
| 100 | +result in memory leaks. |
97 | 101 |
|
98 | 102 | #### `abortSignal.aborted` |
99 | 103 | <!-- YAML |
|