You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
### How do I stop retries when the process receives SIGINT (Ctrl+C)?
234
+
235
+
Use an [`AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController) to signal cancellation on SIGINT, and pass its `signal` to `pRetry`:
236
+
237
+
```js
238
+
importpRetryfrom'p-retry';
239
+
240
+
constcontroller=newAbortController();
241
+
242
+
process.once('SIGINT', () => {
243
+
controller.abort(newError('SIGINT received'));
244
+
});
245
+
246
+
try {
247
+
awaitpRetry(run, {signal:controller.signal});
248
+
} catch (error) {
249
+
console.log('Retry stopped due to:', error.message);
250
+
}
251
+
```
252
+
253
+
The package does not handle process signals itself to avoid global side effects.
254
+
231
255
## Related
232
256
233
257
-[p-timeout](https://github.com/sindresorhus/p-timeout) - Timeout a promise after a specified amount of time
0 commit comments