Fix lastLine() killing the whole process via log.Fatal - #93
Merged
Conversation
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>
This was referenced Aug 9, 2026
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.
Problem
lastLine()(used to read the flash-progress file) callslog.Fatal(err)iftail -n1fails - which happens whenever the progress file doesn't exist yet (right at the start of a flash, or when drivinghandleSerialCommanddirectly, as in tests).log.Fatalcallsos.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 throughTestHandleSerialCommand, since theSTATUSsubtest 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 opaqueexit status 1with no--- FAILtrace, making it non-obvious.Fix
Return
""instead of crashing. The only caller (refreshProgress) already handles a non-numeric/empty result by falling back to0viastrconv.Atoi's error case - so this is a correct, already-expected fallback path, not a new one.Test plan
go buildpassesgo test ./...now runs to completion and passes (previously died partway through with no clear indication why)🤖 Generated with Claude Code