-
Notifications
You must be signed in to change notification settings - Fork 494
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
Catch Promise rejection on SIGINT #92
Catch Promise rejection on SIGINT #92
Conversation
🦋 Changeset is good to goLatest commit: ed95a23 We got this. Not sure what this means? Click here to learn what changesets are. |
Codecov Report
@@ Coverage Diff @@
## master #92 +/- ##
==========================================
- Coverage 83.23% 82.61% -0.62%
==========================================
Files 31 31
Lines 811 817 +6
Branches 144 145 +1
==========================================
Hits 675 675
- Misses 125 131 +6
Partials 11 11 Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉
.then((responses: any) => responses[name]) | ||
.catch(() => { | ||
handlePromiseOnSigint("Please type Y or N"); | ||
}); | ||
} | ||
|
||
async function askList( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we use askList anywhere now so we should probably remove it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I noticed but felt like I should cover it in case it was meant to be used in the future... I'll remove it though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this! I don't know if we need to log anything in this situation, as most CLIs just exit silently.
Second thing, can we check the type of error and re-throw for errors other than manual process exits to make sure we don't swallow genuine errors.
@Noviny sure, I'll make the change. Regarding exiting silently vs showing a message In my mind, it's good to provide the user with some feedback even if it's redundant (say I know I need to pick a package from the checklist but I want to exit now and hit CTRL + C) re-iterating that a selection is needed or a question needs to be answered kind of sticks to the back of my head if I re-run the command again and go through the flow. That being said, happy to do it either way. I'll wait for your response before moving forward. |
Thinking about this a bit more, I think I digressed...
IMHO I think it's worth giving the user some context when they are exiting in the middle of the flow (specifically in a step, like answering a question) even though they are quitting purposely. (So, I get why you're saying it) either way is fine with me. :)
Technically this was already happening, I didn't actually plug into the Ctrl + C (SIGINT) event, rather I addressed the errors you were seeing (and the ones that popped whenever quitting the flow) which were basically that the promises building the prompts/questions didn't have a |
Possibly some context line is good, but the context seems more like If we wanted to let them know what step they exited on, we could go with:
etc, but that can be seen already in the terminal. This is also why I want to detect for SIGINT, as it's the only known error and just rethrow other things. The way this is set up, it will display this message for any error that occurs during steps, and if there is a bug that causes the process to crash, it will hide that, and return this message that implies it's the user's fault (in how I am reading this). |
Fair enough, I'll remove the |
…ltag3/changesets into catch-promise-rejection-on-sigint
@Noviny Should be all good for another review :) |
Open to feedback fixes #88