-
Notifications
You must be signed in to change notification settings - Fork 2
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
Protocol error (promised bytes vs received bytes) when using web / fetch client #13
Comments
Hey! Can you tell me the protocol you are using? |
Can you also tell me the |
Hey @srikrsna-buf, thanks for the quick response.
I'm using Connect.
Sure. When I make the request that breaks, here's the headers:
And the message back is:
|
That's odd there's a check to remove the content-length header if the content-encoding is set, because fetch implementations decode the body but don't change the header. connect-dart/packages/connect/lib/src/web.dart Lines 70 to 77 in c5dfa2e
I'll reproduce and identify a fix, thanks for the detailed report. |
Thanks @srikrsna-buf, appreciate you jumping on this! I would have contributed a PR myself but I'm out my depth here. I did spot that. I tried removing it, and also tried tweaking it to be case insensitive etc... It didn't seem to have any impact. I've been testing my app the past few days with the exceptions removed (literally just deleted the checks), and it seems fine - which suggests the toBytes implementation doesn't actually rely on the content-length header for anything meaningful. Hope that helps! |
I am also experiencing this but for only one out two services. Can also confirm it is only only with the web transport. |
It took me some time to figure this one out as I was unable to replicate with a regular setup, I should've looked at the response headers more closely. Can you add |
Describe the bug
I've been building a Flutter app that uses ConnectRPC. Everything was working fine on the MacOS build, but when I tried building and running on the web I started getting protocol errors.
To Reproduce
When I try and call my server endpoint, I get: Protocol error: promised 361 bytes, received 408.
The exception itself is coming from length checking in the
toBytes
function inlib/src/protocol/sink.dart
. I tried removing the length checks, and this does seem to resolve the problem.Here's the relevant protobuf definitions, I'm calling the login service:
Now, here's where I instantiate the client in my codebase:
Interestingly, this doesn't happen for all responses. If I mistype the password, I receive the message back from the server saying the user was not found, so no protocol error there.
Environment (please complete the following information):
0.3.0
3.5.4
3.24.5
web
The text was updated successfully, but these errors were encountered: