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
Contributor

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
@golang golang locked and limited conversation to collaborators Aug 8, 2024
anatoliinzrnk added a commit to anatoliinzrnk/go-sync that referenced this issue Sep 25, 2024
Fixes golang/go#59355

Change-Id: Ib6a88e7e5fefe7b0d5672035af16d109aabcbf1e
Reviewed-on: https://go-review.googlesource.com/c/sync/+/481255
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants