-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Streaming forward handler fix chunk encoding #479
Streaming forward handler fix chunk encoding #479
Conversation
5230ad8
to
d7127a6
Compare
Could you add a |
d7127a6
to
51194e1
Compare
@achew22 I added a test, let me know what needs to be updated. Also whats the reason for {"result": ...} in the JSON response? |
That's a good question! I didn't write that code so I'm performing code archeology here, but I think the logic is that you don't want to return the proto directly so that you can put additional information in later without breaking people. If we wanted to add "code", a status code for the request, you could do that safely now but you couldn't if that weren't the case. Looks good to me! Thanks for your contribution |
The JSON stream output is no longer newline separated, is this intentional? |
@aelsabbahy yes. Is this behaviour breaking something for you? |
I happened to The readme needs to be updated if this is the way it'll work moving forward:
Also, what's the best way to parse the response now that newline is no longer a delimiter? I'm also noticing https://github.com/tmc/grpc-websocket-proxy might not be working well with this change messages only send at the end, rather than one at a time. But I'm only currently testing with https://github.com/danielstjules/wsc so maybe not a full end-end test. |
Yes my proxy relies on newline separation. |
I think the fix here is to additionally emit a "\n" into the stream to cause the data to have the newline delimit since returning to the old code would break the encoding and reopen this bug. Does anyone object to that? I don't have an environment in which I can test that easily. @aelsabbahy, could you validate my theory by adding
in |
This is a breaking behaviour. Can this be put behind a check for json content-type, or being part of the marshaller? This was breaking my code by not being able to control encoding. |
Let's do it in a 2nd PR. Does my proposal fix it? |
@achew22 Its not very clean but would emcfarlane@5a75208 work? The issue is when not using JSON in the stream. I have a custom marshaler that works similarly to the new ProtoMarhshaler 0395325 but removes the stream map[]s added by https://github.com/grpc-ecosystem/grpc-gateway/blob/master/runtime/handler.go#L149 . |
(off topic) (On topic) |
@aelsabbahy could check if the marshaler satisfies a Delimiter() interface? |
Go http lib handles chunking of messages. This fixes encoding which corrupts non text messages.