Skip to content

BUG: http.Get() without timeout in update check and GitHub API calls #717

@andrinoff

Description

@andrinoff

Describe the bug
Multiple http.Get() calls use default HTTP client with no timeout, potentially causing indefinite hangs if GitHub API is slow or unresponsive.

To reproduce

  1. Examine main.go line 2756 (checkForUpdatesCmd):
const api = "https://api.github.com/repos/floatpane/matcha/releases/latest"
resp, err := http.Get(api)  // No timeout
  1. Examine main.go line 3000 (runUpdate):
resp, err := http.Get(api)  // No timeout
  1. Examine main.go line 3138 (runUpdate asset download):
respAsset, err := http.Get(assetURL)  // No timeout
  1. Network hang or slow GitHub API could block indefinitely

Expected behavior
HTTP requests should have reasonable timeout. Use custom http.Client with timeout.

Additional context

  • Good first issue: straightforward HTTP client improvement
  • Affects update checking and automatic updates
  • Default http.Client has no timeout - can hang forever
  • Best practice: 10-30 second timeout for external API calls

Suggested fix:

client := &http.Client{
    Timeout: 30 * time.Second,
}
resp, err := client.Get(api)

Or define once at package level:

var httpClient = &http.Client{
    Timeout: 30 * time.Second,
}

OS
All platforms

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions