question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Parsing of grpc-web trailers is incorrect

See original GitHub issue

See https://github.com/timostamm/protobuf-ts/blob/fefa69ba2bbad48aa6e28264b90b564b0f9846ec/packages/grpcweb-transport/src/grpc-web-format.ts#L303

And the docs for String#split()

Limit - A non-negative integer specifying a limit on the number of substrings to be included in the array. If provided, splits the string at each occurrence of the specified separator, but stops when limit entries have been placed in the array. Any leftover text is not included in the array at all.

This means that a response trailer that looks like this

grpc-status:9
grpc-message:Precondition failed for updated time (actual: 1633092892, expected: 1633092890)

Will result in an error being thrown like this: RpcError: Precondition failed for updated time (actual

The official grpc-web client parses the trailers with https://github.com/grpc/grpc-web/blob/3956560ad01b4af0a2a5c29c081f5bbd1424e85d/javascript/net/grpc/web/grpcwebclientreadablestream.js#L349-L358 where it finds the first index of :, everything before that is key and everything after is value.

This seems like an easy fix. I’ll try to put up a PR to address this over the weekend.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
jcreadycommented, Oct 4, 2021

😅 I was working on it this weekend. I don’t quite have a PR ready for you yet, but here are a few things I’ve noticed already:

0reactions
timostammcommented, Oct 11, 2021

Ha, so it doesn’t even do as I was arguing?

From the manual:

Response trailers are a very useful feature, but for simple unary calls, awaiting two promises is cumbersome. For this reason, the UnaryCall itself is awaitable, and will reject if an error status is received.

Apparently not, sorry about the confusion. gRPC clients for C# do behave like I argued, and @grpc/grpc-js does so as well, but it looks like I just pondered changing our implementation, and didn’t go forward with it. Changing the response promise to reject would definitely be a breaking change, so let’s hold on moving this.

FYI: Going through your PR at the moment (huge thanks in advance).

Read more comments on GitHub >

github_iconTop Results From Across the Web

grpc-web error code: 14, codeName: UNAVAILABLE, ...
grpc-web error code: 14, codeName: UNAVAILABLE, message: Missing trailers #505 ... when sending the response or in the client when parsing the response) ......
Read more >
Why does gRPC insist on trailers?
Whether it's because I was wrong, or failed to make the argument [for HTTP trailers support], I strongly suspect organizational boundaries had a...
Read more >
GRPC Core: Status codes and their use in gRPC
Code Number Description OK 0 Not an error; returned on success. FAILED_PRECONDITION 9 OUT_OF_RANGE 11
Read more >
I get gRPC Invalid UTF-8 when I make a request to ...
when I use another gRPC client, such as bloomRPC, the call is successful and I get the correct data. The Flutter app call...
Read more >
Troubleshoot gRPC on .NET Core
Mismatch between client and service SSL/TLS configuration; Call a gRPC service with an untrusted/invalid certificate; Call insecure gRPC ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found