Skip to content

Commit 93b88fb

Browse files
committed
docs
1 parent ec2feee commit 93b88fb

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/mongo_types.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -484,21 +484,24 @@ export type Abortable = {
484484
* @remarks
485485
* **NOTE:** Currently, aborting an in-progress operation causes the in-use Connection to close.
486486
* If signals are aborted at a high rate it will cause many connections that are otherwise healthy
487-
* to be discarded. We plan to mitigate this in a future release, please follow NODE-6062.
487+
* to be discarded. We plan to mitigate this in a future release, please follow NODE-6062 (`timeoutMS` expiration suffers the same limitation).
488+
*
489+
* AbortSignals are likely a best fit for human interactive interruption (ex. ctrl-C) where the frequency
490+
* of cancellation is reasonably low. If a signal is programmatically aborted for 100s of operations you can empty
491+
* the driver's connection pool.
488492
*
489493
* @example
490494
* ```js
491495
* const controller = new AbortController();
492496
* const { signal } = controller;
493-
* req.on('close', () => controller.abort(new Error('Request aborted by user')));
497+
* process.on('SIGINT', () => controller.abort(new Error('^C pressed')));
494498
*
495499
* try {
496500
* const res = await fetch('...', { signal });
497501
* await collection.findOne(await res.json(), { signal });
498502
* catch (error) {
499-
* // depends on abort reason used, but by default this is true.
500-
* if (error.name === 'AbortError') {
501-
* error === signal.reason; // true
503+
* if (error === signal.reason) {
504+
* // signal abort error handling
502505
* }
503506
* }
504507
* ```

0 commit comments

Comments
 (0)