Skip to content

fix: cancel context when using errgroup for error return earlier#213

Merged
gaius-qi merged 1 commit into
mainfrom
fix/errgroup-cancel
Jun 20, 2025
Merged

fix: cancel context when using errgroup for error return earlier#213
gaius-qi merged 1 commit into
mainfrom
fix/errgroup-cancel

Conversation

@chlins

@chlins chlins commented Jun 20, 2025

Copy link
Copy Markdown
Member

This pull request introduces enhancements to the concurrency handling across several backend functions by integrating context-aware error groups. The changes ensure that goroutines respect context cancellation, improving the robustness and responsiveness of the application.

Enhancements to concurrency handling:

  • Updated all functions (Extract, Fetch, Pull, pullByDragonfly, and Push) to use errgroup.WithContext instead of errgroup.Group, enabling context propagation and cancellation. (pkg/backend/extract.go: [1] pkg/backend/fetch.go: [2] pkg/backend/pull.go: [3] [4] pkg/backend/pull_by_d7y.go: [5] pkg/backend/push.go: [6]

  • Added a select block in each goroutine to check for context cancellation (<-ctx.Done()), ensuring that ongoing operations terminate gracefully if the context is canceled. (pkg/backend/extract.go: [1] pkg/backend/fetch.go: [2] pkg/backend/pull.go: [3] pkg/backend/pull_by_d7y.go: [4] pkg/backend/push.go: [5]

Signed-off-by: chlins <chlins.zhang@gmail.com>
@chlins chlins added the enhancement New feature or request label Jun 20, 2025

@gaius-qi gaius-qi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@gaius-qi gaius-qi merged commit 4c8706d into main Jun 20, 2025
5 checks passed
@gaius-qi gaius-qi deleted the fix/errgroup-cancel branch June 20, 2025 08:25
SAY-5 added a commit to SAY-5/modctl that referenced this pull request May 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants