Skip to content

fix: surface update notice even when a command fails#39

Merged
Taure merged 1 commit into
mainfrom
fix/notify-on-failed-command
Jul 16, 2026
Merged

fix: surface update notice even when a command fails#39
Taure merged 1 commit into
mainfrom
fix/notify-on-failed-command

Conversation

@Taure

@Taure Taure commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Problem

update.Notify ran only at the tail of main(). Commands that fail exit via fatal()os.Exit(1) before reaching it, and os.Exit skips deferred functions, so a defer in main wouldn't fix it. Net effect: a brand-new user whose early commands fail (asobi health with no backend → connection refused, exactly what surfaced this) is never nudged to upgrade.

Fix

Single exit chokepoint:

func exit(code int) { notifyUpdate(); os.Exit(code) }

fatal() and the direct os.Exit(1) sites now route through exit(), so every termination path surfaces the notice. Skip rules (version/help/upgrade, CI, ASOBI_NO_UPDATE_CHECK, dev builds) are unchanged — they live in update.shouldCheck.

Test

Added notifyUpdateTo(io.Writer) seam + TestNotifyUpdateWiring: seeds a fresh cache with a newer release and asserts the failing-command path emits the notice, hermetically (no network).

Verified end-to-end with a -ldflags -X main.version=v0.0.1 build: failing health prints the error then A new asobi is available: v9.9.9; version stays silent.

The update notifier ran only at the end of main(), so any command that
exited via fatal() (e.g. `asobi health` against a down backend) called
os.Exit before the notice - and os.Exit skips deferred work, so a
main-level defer wouldn't help either. New users, whose early commands
often fail, never got nudged to upgrade.

Route every exit through a single exit() chokepoint that emits the notice
first; fatal() and the direct os.Exit sites now go through it. Add a
writer seam (notifyUpdateTo) and a hermetic test driving the failing-
command path off a seeded cache.
@Taure Taure closed this Jul 16, 2026
@Taure Taure reopened this Jul 16, 2026
@Taure
Taure merged commit 04dc185 into main Jul 16, 2026
2 checks passed
@Taure
Taure deleted the fix/notify-on-failed-command branch July 16, 2026 22:00
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.

1 participant