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

Don't check the response body close error in the client #336

Merged
merged 2 commits into from
Nov 29, 2021

Conversation

cespare
Copy link
Contributor

@cespare cespare commented Nov 4, 2021

If we successfully read the response all the way to EOF and decode it, that constitutes a successful RPC. If the body close happens to return a non-nil error, the client shouldn't care.

The context where this came up is that Go 1.17.3 seemingly introduced a bug (reported here) where sometimes the response body Close method returns a spurious error. This meant that upgrading to Go 1.17.3 caused Twirp requests to start failing for us.

The actual bug is on the Go side, but the fact that nobody noticed and the tests didn't catch it is more evidence that checking this error is uncommon and unnecessary.

(And if I may editorialize slightly: this is why the errcheck linter is not a good blanket policy.)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@mellis
Copy link
Contributor

mellis commented Nov 15, 2021

Hello, thank you for the PR. The change has some extraneous changes due to an older version of protoc being used. Can you please use the same version that was previously used, v3.17.1, to keep it a bit cleaner.

@cespare cespare force-pushed the remove-response-close-check branch from 00fd4e4 to 1e64f8b Compare November 15, 2021 23:05
The 'go generate' command used sh to run a bash script. That script uses
'set -o pipefail', but that is Bash-specific. Instead, run the script
directly, so that we use Bash.
If we successfully read the response all the way to EOF and decode it,
that constitutes a successful RPC. If the body close happens to return a
non-nil error, the client shouldn't care, since it was able to fully
read the response.
@cespare cespare force-pushed the remove-response-close-check branch from 1e64f8b to e0e9a4d Compare November 15, 2021 23:13
@cespare
Copy link
Contributor Author

cespare commented Nov 15, 2021

Hello, thank you for the PR. The change has some extraneous changes due to an older version of protoc being used. Can you please use the same version that was previously used, v3.17.1, to keep it a bit cleaner.

Sure, done. Though if you care about that, ISTM that the tooling ought to check for the particular version.

@mellis
Copy link
Contributor

mellis commented Nov 29, 2021

Thank you for the update, looks good 👍

Though if you care about that, ISTM that the tooling ought to check for the particular version.

I agree.

@mellis mellis merged commit fce72e0 into twitchtv:main Nov 29, 2021
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.

2 participants