Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/sync: Use WithCancelCause for errgroup.WithContext #59355

Closed
jonjohnsonjr opened this issue Mar 31, 2023 · 2 comments
Closed

x/sync: Use WithCancelCause for errgroup.WithContext #59355

jonjohnsonjr opened this issue Mar 31, 2023 · 2 comments

Comments

@jonjohnsonjr
Copy link
Contributor

jonjohnsonjr commented Mar 31, 2023

When using errgroup.WithContext, the first non-nil error encountered will cancel the context and then be returned by the next call to Wait. This works well when you actually call Wait, but if that canceled context prevents you from calling Wait, you just get an unhelpful context canceled error.

I believe the new context.WithCancelCause added in 1.20 would fix this, so I propose we use that instead of this context.WithCancel so we can propagate the error here, here, and here.

@gopherbot gopherbot added this to the Proposal milestone Mar 31, 2023
@gopherbot
Copy link

Change https://go.dev/cl/481255 mentions this issue: errgroup: use WithCancelCause to cancel context

peczenyj added a commit to peczenyj/cache that referenced this issue Aug 4, 2023
peczenyj added a commit to peczenyj/cache that referenced this issue Aug 4, 2023
@rsc
Copy link
Contributor

rsc commented Aug 9, 2023

Seems to have landed without a proposal acceptance but too late to do anything about that now.

@rsc rsc changed the title proposal: x/sync: Use WithCancelCause for errgroup.WithContext x/sync: Use WithCancelCause for errgroup.WithContext Aug 9, 2023
@rsc rsc modified the milestones: Proposal, Backlog Aug 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Accepted
Development

No branches or pull requests

3 participants