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

Gracefully exit login and publish commands on Ctrl+C (SIGINT) in the new webAuthn flow #5243

Merged
merged 4 commits into from Aug 2, 2022

Conversation

neeldani
Copy link
Contributor

@neeldani neeldani commented Aug 2, 2022

What / Why

This PR resolves the bug which did not allow users to exit the CLI process on hitting CTRL + C for npm publish --auth-type=web and npm login auth-type=web commands.

Approach

We use readline to prompt the user to hit ENTER. However, the first time the user hits CTRL+C, it closes the readline instance (docs). The second CTRL+C then kills the CLI process. This PR adds an event listener which listens to readline's SIGINT event (docs) and then gracefully kills the CLI process from the cb function.

Note: The experience shown after hitting CTRL+C is kept similar to the existing experience when the user hits CTRL+C for login and publish commands without the auth-type=web flag

The PR also adds a test case to validate the same.

Experience

Login

login-sigint.mov

Publish

publish-sigint.mov

References

Resolves #5231

@neeldani neeldani marked this pull request as ready for review August 2, 2022 13:08
@neeldani neeldani requested a review from a team as a code owner August 2, 2022 13:08
@neeldani neeldani changed the title Gracefully exit on Ctrl+C (SIGINT) Gracefully exit login and publish commands on Ctrl+C (SIGINT) in the new webAuthn flow Aug 2, 2022
@npm-cli-bot
Copy link
Collaborator

no statistically significant performance changes detected

timing results
app-large clean lock-only cache-only cache-only
peer-deps
modules-only no-lock no-cache no-modules no-clean no-clean
audit
npm@8 35.161 ±2.05 15.075 ±0.04 13.809 ±0.22 15.954 ±0.80 2.427 ±0.00 2.422 ±0.01 1.985 ±0.00 9.434 ±0.06 1.965 ±0.02 3.467 ±0.63
#5243 35.449 ±2.44 15.119 ±0.02 13.797 ±0.18 15.923 ±0.58 2.478 ±0.03 2.480 ±0.07 1.997 ±0.03 9.417 ±0.01 1.976 ±0.00 3.051 ±0.12
app-medium clean lock-only cache-only cache-only
peer-deps
modules-only no-lock no-cache no-modules no-clean no-clean
audit
npm@8 24.653 ±0.25 11.584 ±0.08 10.232 ±0.07 11.110 ±0.50 2.286 ±0.05 2.246 ±0.02 2.016 ±0.01 6.996 ±0.06 1.919 ±0.02 2.636 ±0.01
#5243 25.698 ±0.16 11.757 ±0.01 10.339 ±0.05 11.436 ±0.61 2.269 ±0.00 2.249 ±0.03 2.044 ±0.03 7.006 ±0.10 1.913 ±0.01 2.651 ±0.01

@neeldani neeldani self-assigned this Aug 2, 2022
@nlf nlf merged commit d315ead into latest Aug 2, 2022
@nlf nlf deleted the neeldani/kill-polling-on-sigint branch August 2, 2022 15:57
@nlf nlf mentioned this pull request Aug 3, 2022
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

Successfully merging this pull request may close these issues.

[BUG] Hitting Ctrl + C does not kill the polling of the CLI in the first go while logging in
3 participants