forked from redwoodjs/redwood
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(cli): Prevent multiple update available messages (redwoodjs#8809)
**Problem** @Tobbe highlighted a case where the update available message would trigger more than once and would result in output like so: ![Screenshot from 2023-07-01 14-34-45](https://github.com/redwoodjs/redwood/assets/56300765/7f7f3bb9-e3fd-4ac5-a6e3-9060c4f08cd6) This was happening because some commands were spawning child commands which would show the message too. Adding a lock to make all processes aware an update message is pending fixes this. **How to reproduce** 1. Delete `./redwood/updateCheck/data.json` to ensure an update check will be triggered. 2. Run some simple command like `yarn rw info` to trigger an update check. 3. Wait a few seconds to ensure the background update check has completed. 4. Run a command which spawns child commands like `yarn rw build web` which will spawn a prerender command. 5. Observe the duplicate messages. **Changes** 1. A lock is used to make any spawned process aware that an existing process is already going to show the update message. This approach means it'll always be the top process that outputs the message and not any of the child processes. 6. Adds a check to the `isLockSet` which ensure stale locks are ignored. We only allow locks to be valid for 1 hour (arbitrary decision by me here). This covers the case where due to some error the lock file persists longer than it should. Tests have been updated accordingly. **Notes** I didn't intend to bloat this PR with the new stale check. If needed I'll pull it out this PR and make a new one - I'd rather just have it here.
- Loading branch information
1 parent
7cc5564
commit fd14fd5
Showing
4 changed files
with
93 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters