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

Try to read full prefix in envelope reader #580

Merged
merged 2 commits into from
Oct 6, 2023
Merged

Try to read full prefix in envelope reader #580

merged 2 commits into from
Oct 6, 2023

Conversation

njiang747
Copy link
Contributor

I believe this fixes a bug where calling to r.reader.Read before all 5 bytes of the prefixes are ready causes an unnecessary ErrUnexpectedEOF (resulting in a client error invalid_argument: protocol error: incomplete envelope: unexpected EOF).

Switching to use io.ReadFull guarantees that the envelopReader will wait until the full prefixes is available before proceeding. Error handling should be identical to before due to the semantics of io.ReadFull. If fewer than 5 bytes are read and then EOF is hit, it will return ErrUnexpectedEOF. If any other error is hit, it will be returned as expected.

@CLAassistant
Copy link

CLAassistant commented Sep 2, 2023

CLA assistant check
All committers have signed the CLA.

@emcfarlane
Copy link
Contributor

emcfarlane commented Oct 6, 2023

Hey @njiang747 , I think the fix is a great find! I added a testcase to show that fails when removing your patch.

@jhump jhump merged commit 57f56b8 into connectrpc:main Oct 6, 2023
7 checks passed
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.

4 participants