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

Return context.Cause(ctx) as error so we can use custom timeout errors #10815

Merged
merged 2 commits into from
Mar 6, 2025

Conversation

zenador
Copy link
Contributor

@zenador zenador commented Mar 5, 2025

What this PR does

To use https://pkg.go.dev/context#WithTimeoutCause , we need to return the cause as error, which is the normal behaviour, except that when we use https://github.com/golang/sync/blob/master/semaphore/semaphore.go#L49 in this code, it does not use the cause as error. To fix that, we check the error returned from there and replace it with the cause if relevant. Without this change, using WithTimeoutCause has no effect when calling Do on limitedParallelismRoundTripper.

Which issue(s) this PR fixes or relates to

N/A

Checklist

  • Tests updated.
  • Documentation added.
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX].
  • about-versioning.md updated with experimental features.

Minor change which by itself should not result in any user-facing changes, but this makes other changes possible.

@zenador zenador requested a review from a team as a code owner March 5, 2025 19:24
@zenador zenador force-pushed the zenador/qry-mw-limits-err branch from bad130c to c64fbf4 Compare March 5, 2025 19:38
Copy link
Contributor

@dimitarvdimitrov dimitarvdimitrov left a comment

Choose a reason for hiding this comment

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

nice find

@zenador zenador enabled auto-merge (squash) March 6, 2025 03:24
@zenador zenador merged commit 75ec258 into main Mar 6, 2025
28 checks passed
@zenador zenador deleted the zenador/qry-mw-limits-err branch March 6, 2025 03:36
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.

3 participants