You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
XhrClientConnection's implementation may set these http headers twice:
Content-Type
X-User-Agent
X-Grpc-Web
This is problematic, for instance, when running flutter web (in browser platform). I believe it is expected for grpc-web to have this header:
X-Grpc-Web: 1
However, if this is set twice via underlying XHttpRequest api (calling request.setRequestHeader('X-Grpc-Web', '1'); twice) would produce the following instead (in latest Chrome browser):
X-Grpc-Web: 1, 1
...thus breaking the protocol.
Repro steps
Initialize GrpcWebClientChannel client
Make any grpc-web api calls, leave CallOptions.metadata's Content-Type empty
Expected result: grpc-web requests successful
Actual result: indeterminate errors, usually timeout (in my case the api call was interpreted as a native grpc call by envoy proxy)
We are going to revert offending change and publish a fixed version of the package, but most likely this is not going to happen earlier than next week.
XhrClientConnection's implementation may set these http headers twice:
This is problematic, for instance, when running flutter web (in browser platform). I believe it is expected for grpc-web to have this header:
However, if this is set twice via underlying XHttpRequest api (calling
request.setRequestHeader('X-Grpc-Web', '1');
twice) would produce the following instead (in latest Chrome browser):...thus breaking the protocol.
Repro steps
GrpcWebClientChannel
clientContent-Type
emptyExpected result: grpc-web requests successful
Actual result: indeterminate errors, usually timeout (in my case the api call was interpreted as a native grpc call by envoy proxy)
Details
The offending code:
grpc-dart/lib/src/client/transport/xhr_transport.dart
Line 188 in cb1c0ea
When content type metadata from CallOptions is null,
XhrClientConnection
will fill in some defaults.grpc-dart/lib/src/client/transport/xhr_transport.dart
Line 169 in cb1c0ea
It copies metadata into http request headers.
grpc-dart/lib/src/client/transport/xhr_transport.dart
Line 174 in cb1c0ea
The same header is set again, introducing the erroneous header values described above.
Equivalent compiled javaScript code:
Reference form MDN:
https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/setRequestHeader
The text was updated successfully, but these errors were encountered: