fix(notifier): suppress stale update notice during self-update#24
Merged
Conversation
The update notifier registered a `process.on("exit")` handler at startup
that captured the cached `latestVersion` in its closure. When the
`self-update` command then upgraded the binary in the same process, the
already-registered handler still printed "Update available: x → y" on
exit — pointing at the very version the user just installed.
Skip the notifier entirely when argv contains `self-update`. The command
itself reports the upgrade outcome, so the footer notice would be
redundant even on the no-op "already up to date" path.
Add a SKIP_COMMANDS set alongside the existing SKIP_FLAGS so the two
classes of skip-reasons stay distinct, and cover the new gate with a
focused test.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
wt self-updateprinted a staleUpdate available: 0.7.3 → 0.8.0 · run wt self-updateline right after a successful upgrade.Root cause: the notifier runs at bootstrap, reads the cache, and registers a
process.on("exit")handler withlatestVersioncaptured in its closure.self-updatethen replaces the binary and writes the cache (writeUpdateCacheinself-update.ts), but the exit handler is already armed with the pre-upgrade version and fires anyway.Fix: skip the notifier entirely when argv contains the
self-updatecommand. The command reports its own outcome, so the footer notice is redundant on both the "already up to date" and "upgraded" paths.Changes
src/cli/update-notifier.ts— newSKIP_COMMANDSset alongsideSKIP_FLAGS; combined argv check.src/cli/update-notifier.test.ts— covers the new gate.Test plan
pnpm typecheckpnpm lintbun test(513 pass, +1 new)wt self-updatewhile a stale cache says "update available" — no footer line should followDone!.