Skip to content

Comments

Replace direct equality checks with errors.Is for context.Canceled#10

Merged
Gustash merged 4 commits intomainfrom
copilot/sub-pr-9
Dec 9, 2025
Merged

Replace direct equality checks with errors.Is for context.Canceled#10
Gustash merged 4 commits intomainfrom
copilot/sub-pr-9

Conversation

Copy link
Contributor

Copilot AI commented Dec 9, 2025

Direct equality comparison with context.Canceled fails when errors are wrapped. This affects cancellation handling across install, update, launch, and download operations.

Changes

  • Replace err == context.Canceled with errors.Is(err, context.Canceled) in:
    • cmd_launch.go - game launch cancellation
    • cmd_install.go - install cancellation
    • cmd_update.go - update cancellation
    • download/downloader.go - download progress and worker cancellation (2 locations)

Example

// Before
if err == context.Canceled {
    return nil
}

// After  
if errors.Is(err, context.Canceled) {
    return nil
}

This ensures proper detection of context cancellation even when errors are wrapped by intermediate layers.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] WIP address feedback on child process implementation Replace direct equality checks with errors.Is for context.Canceled Dec 9, 2025
Copilot AI requested a review from Gustash December 9, 2025 18:41
Base automatically changed from fix/child-process to main December 9, 2025 19:14
@Gustash Gustash marked this pull request as ready for review December 9, 2025 19:22
Copilot AI review requested due to automatic review settings December 9, 2025 19:22
@Gustash Gustash merged commit e8cf9d5 into main Dec 9, 2025
6 of 7 checks passed
@Gustash Gustash deleted the copilot/sub-pr-9 branch December 9, 2025 19:22
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves error handling for context cancellation across multiple operations by replacing direct equality checks with errors.Is(). This ensures proper detection of context cancellation even when errors are wrapped by intermediate layers.

Key changes:

  • Updated cancellation checks in command handlers (launch, install, update)
  • Fixed download worker and progress cancellation detection
  • Added errors package imports where needed

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
download/downloader.go Updated two context cancellation checks in download progress handling and worker routine to use errors.Is()
cmd_update.go Updated update cancellation check to use errors.Is() for proper wrapped error detection
cmd_install.go Updated install cancellation check to use errors.Is() for proper wrapped error detection

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

2 participants