Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to stop retry on SIGINT #48

Open
40x opened this issue Apr 13, 2021 · 1 comment
Open

how to stop retry on SIGINT #48

40x opened this issue Apr 13, 2021 · 1 comment

Comments

@40x
Copy link

40x commented Apr 13, 2021

I dont see a way to stop the retry on SIGINT? Right now we throw an exception throw new pRetry.AbortError(''); which isn't clean but something like operation.stop from the underlying library should help. Is this possible?

@sindresorhus
Copy link
Owner

That is the best way to handle it. When you throw an AbortError, this package uses operation.stop internally:

p-retry/index.js

Lines 57 to 58 in 810f309

if (error instanceof AbortError) {
operation.stop();

This package cannot subscribe to SIGINT itself as that causes side-effects. So, it's up to you to handle SIGINT. We also have to reject the promise on AbortError, as otherwise the promise would be forever hanging, which is never what you want.

I'm open to ideas to improve this, but I don't see a way to make it better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants