Skip to content

Fix lastLine() killing the whole process via log.Fatal - #93

Merged
eliasbakken merged 1 commit into
mainfrom
fix/lastline-log-fatal
Aug 10, 2026
Merged

Fix lastLine() killing the whole process via log.Fatal#93
eliasbakken merged 1 commit into
mainfrom
fix/lastline-log-fatal

Conversation

@eliasbakken

Copy link
Copy Markdown
Contributor

Problem

lastLine() (used to read the flash-progress file) calls log.Fatal(err) if tail -n1 fails - which happens whenever the progress file doesn't exist yet (right at the start of a flash, or when driving handleSerialCommand directly, as in tests). log.Fatal calls os.Exit(1), taking down the entire server process on what's actually an expected, transient condition.

Found this while running go test ./... for an unrelated change - the whole suite was silently dying partway through TestHandleSerialCommand, since the STATUS subtest exercises this exact path without the progress file existing yet. No test after it in the package ever actually ran, and the failure showed only as an opaque exit status 1 with no --- FAIL trace, making it non-obvious.

Fix

Return "" instead of crashing. The only caller (refreshProgress) already handles a non-numeric/empty result by falling back to 0 via strconv.Atoi's error case - so this is a correct, already-expected fallback path, not a new one.

Test plan

  • go build passes
  • go test ./... now runs to completion and passes (previously died partway through with no clear indication why)

🤖 Generated with Claude Code

lastLine() is used to read the last line of the in-progress flash
progress file. Before that file exists (right at the start of a
flash, or when driving handleSerialCommand directly as in tests), the
underlying `tail` command fails - and log.Fatal called os.Exit(1) on
that, taking down the entire server process rather than just this one
read.

The only caller already handles a non-numeric/empty result by
falling back to 0 (strconv.Atoi's error case), so returning "" here
instead of crashing is a correct, already-expected fallback path, not
a new one.

This was silently killing the whole `go test ./...` run partway
through TestHandleSerialCommand, since the STATUS subtest exercises
this exact path without the progress file existing yet - no other
tests after it in the package ever actually ran.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@eliasbakken
eliasbakken merged commit 90747da into main Aug 10, 2026
2 checks passed
@eliasbakken
eliasbakken deleted the fix/lastline-log-fatal branch August 10, 2026 18:30
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