fix(selfupdate): resolve false-negative terminal output by splitting SLA timeouts#310
Open
baltasarblanco wants to merge 1 commit intoGentleman-Programming:mainfrom
Open
Conversation
…SLA timeouts Resolves Gentleman-Programming#230. Replaces the monolithic 7s timeout with independent SLAs for API discovery (5s) and binary execution (60s). This prevents the context from prematurely cancelling background downloads on moderate-latency networks, which previously left a spurious failure marker in the AltScreen buffer.
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.
🔗 Linked Issue
Closes #230
🏷️ PR Type
What kind of change does this PR introduce?
type:bug— Bug fix (non-breaking change that fixes an issue)type:feature— New feature (non-breaking change that adds functionality)type:docs— Documentation onlytype:refactor— Code refactoring (no functional changes)type:chore— Build, CI, or tooling changestype:breaking-change— Breaking change (fix or feature that changes existing behavior)📝 Summary
Resolves a false-negative UI failure where the pre-flight
selfUpdateroutine printed a red✗on the terminal, even though the binary successfully updated.Root Cause:
internal/app/selfupdate.goapplied a shared 7-second context timeout to the entire upgrade flow (API ping + Backup + 9MB tarball download). On moderate-latency networks, the download exceeded the budget. The context cancelled, propagating an error tospinner.Finish(false)and printing✗tostdout. Meanwhile, the OS buffer allowed the atomicos.Renameto succeed in the background. Becausetea.WithAltScreen()hid the original terminal buffer, the user only saw the spurious✗after exiting the TUI.📂 Changes
internal/app/selfupdate.goselfUpdateCheckTimeout) and 60s for execution (selfUpdateExecTimeout). Separated context lifecycle for each phase.🧪 Test Plan
Unit Tests
go test ./...E2E Tests (Docker required)
Manual Verification Details:
Simulated a 15s download delay in upgrade_test.go confirming the success signal. Also tested manually on Ubuntu 22.04 using tc qdisc netem delay to prove the green checkmark renders correctly under network stress.
🤖 Automated Checks
The following checks run automatically on this PR:
Closes/Fixes/Resolves #Nstatus:approvedtype:*Labeltype:*label must be appliedgo test ./...must passcd e2e && ./docker-test.shmust pass✅ Contributor Checklist
💬 Notes for Reviewers
Risk Assessment: