Stop retries on SIGINT (Ctrl+C)
mainTo stop retries when the process receives a signal like SIGINT, use an AbortController and pass its signal to pRetry.
import pRetry from 'p-retry';
const controller = new AbortController();
process.once('SIGINT', () => {
controller.abort(new Error('SIGINT received'));
});
try {
await pRetry(run, {signal: controller.signal});
} catch (error) {
console.log('Retry stopped due to:', error.message);
}