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

Remove timeout logic from ReadRaw functions and add ReadRawWithContext #18708

Merged
merged 6 commits into from
Jan 17, 2023

Conversation

averche
Copy link
Contributor

@averche averche commented Jan 13, 2023

Removing the timeout logic from raw-response functions and adding documentation comments. The following functions are affected:

  • ReadRaw
  • ReadRawWithContext (newly added)
  • ReadRawWithData
  • ReadRawWithDataWithContext

The previous logic of using ctx, _ = c.c.withConfiguredTimeout(ctx) could cause a potential context leak:

Failing to call the CancelFunc leaks the child and its children until the parent is canceled or the timer fires. The go vet tool checks that CancelFuncs are used on all control-flow paths.

Cancelling the context would have caused more issues since the context would be cancelled before the request body is closed.

Resolves: #18658

@averche averche added this to the 1.13.0-rc1 milestone Jan 13, 2023
Copy link
Contributor

@cipherboy cipherboy left a comment

Choose a reason for hiding this comment

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

This makes sense to me, thanks @averche for taking this on!

command/read.go Outdated Show resolved Hide resolved
Copy link
Contributor

@cipherboy cipherboy left a comment

Choose a reason for hiding this comment

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

Very nice! Thank you!

@averche averche enabled auto-merge (squash) January 17, 2023 19:49
@averche averche merged commit ef3e3ea into main Jan 17, 2023
@averche averche deleted the raw-read-fix branch January 18, 2023 04:07
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.

Logical.ReadRawWithDataWithContext cancels response body
3 participants