-
Notifications
You must be signed in to change notification settings - Fork 3.5k
fix: the spinner #8322
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
base: latest
Are you sure you want to change the base?
fix: the spinner #8322
Conversation
My AI friends and I spend a long time to figure this out, but we found a solution that is straight forward. DetailsHere are the input events as they are processed currently, for example with
When This creates a race condition where:
This explains why we see the events out of order:
The issue is that the SolutionWe switched to sequential input management because:
The key insight is to emit the Cancelled user prompts are now handled directly in As suggested, we're now passing the Summary
😃 |
TL;DR
I fixed the spinner, yay! If you like it, buy me a ☕ or 🍕 .
Background
In 10.7.0, a spinner was introduced to the npm cli, a small progress indicator showing that npm is still busy and not dead.
I'm not a JavaScript developer, but I love a good challenge: Debugging and finding a fix for annoying bugs that no one had time to or wanted to fix is as good as sx (well, almost).
Problem
With the spinner came a regression that disrupted the user experience when npm asked for input during login or adding a user: The spinner would show up after the second prompt and drive users nuts.
For example, the username prompt for
npm adduser
would be ok but subsequent prompts for password and email showed the spinner although users were asked to enter something. Very confusing.Root Cause
The was a race condition between turning off the spinner and showing a new prompt.
I tried setting timers, waiting for the next tick, and a flag indicating if there's an active prompt. None worked.
Solution
This PR improves the cli prompt experience by ensuring the progress spinner does not appear between consecutive user prompts (such as username and password).
Demo
Here's a demo of what it looks after this PR 😃 (uses Verdaccio in case you wonder)
References
Ref #7432
Closes #7425
Closes #7583
Enjoy, Marc