Skip to content

Improve update error handling with TTY detection#74

Merged
gricha merged 2 commits intomainfrom
improve-update-error-handling
Jan 10, 2026
Merged

Improve update error handling with TTY detection#74
gricha merged 2 commits intomainfrom
improve-update-error-handling

Conversation

@gricha
Copy link
Copy Markdown
Owner

@gricha gricha commented Jan 10, 2026

Summary

  • Add detailed error reporting for perry update failures (504, 403, timeouts, etc.)
  • Only show error messages in interactive TTY mode - silently exit in CI/scripts
  • Increase fetch timeout from 3s to 5s to reduce false timeouts

Changes

src/update-checker.ts

  • Added FetchVersionResult interface with version, error, and status fields
  • Added fetchLatestVersionWithDetails() for detailed error info
  • Kept fetchLatestVersion() as backward-compatible wrapper

src/index.ts

  • Use process.stdout.isTTY to detect interactive mode
  • Show specific messages for 504 (Gateway Timeout) and 403 (rate limit)
  • In non-TTY mode, silently exit with code 1

Behavior

Scenario TTY (interactive) Non-TTY (scripts/CI)
504 error Shows timeout message Silent exit(1)
403 rate limit Shows rate limit message Silent exit(1)
Other errors Shows error detail Silent exit(1)
Success Shows version info Shows version info

- Add fetchLatestVersionWithDetails() to return detailed error info including HTTP status codes
- Show specific error messages for 504 (Gateway Timeout) and 403 (rate limit) errors
- Only display error messages when running in interactive TTY mode
- Increase fetch timeout from 3s to 5s to reduce false timeouts
- Silently exit with code 1 in non-TTY mode (CI/scripts)
Comment thread src/index.ts Outdated

if (!result.version) {
// Only show detailed error messages in interactive mode (TTY)
if (process.stdout.isTTY) {

This comment was marked as outdated.

- Use process.stderr.isTTY instead of stdout.isTTY since errors go to stderr
- Format code with oxfmt
@gricha gricha merged commit 3c83abe into main Jan 10, 2026
8 checks passed
@gricha gricha deleted the improve-update-error-handling branch January 10, 2026 05:38
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