> ## Content Index
> Fetch the complete content index at: https://datajutsu.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# A Failed gRPC Call Still Returns 200 (and the Error Is in the Headers, Not the Body)
- URL: https://datajutsu.com/grpc-failed-call-returns-200/
- Published: 2026-10-29T18:27:38.000Z
- Updated: 2026-10-29T18:27:38.000Z
- Author: Data Jutsu

The gRPC posts in this series have named the frame header, the compression flag, and the trailers. None of them has said what the bytes look like when a call fails. I wanted that, so I put a failing handler on a real grpc-js server, caught the bytes on the wire, and lined them up next to the success case. The failure was not sitting where I expected.

A failed gRPC call still returns HTTP status 200\. The body is zero bytes, no message frame at all. The verdict is not in the HTTP status line and it is not in the body. It is in the metadata that ends the response stream, grpc-status carrying the code and grpc-message carrying the reason. The success path does the opposite thing: the message frame goes out in the body, and the status, a zero, arrives in the trailing block at the very end of the stream. So success and failure put the status in different places. A client that only reads the body gets nothing on a failure, and the whole answer is riding in the metadata instead.

The message is percent-encoded, but not the way most people would assume. grpc-js uses encodeURI on the details string, not encodeURIComponent. I sent the message bad input with a colon and two commas, and it went out as the space turned to %20 while the colon and both commas stayed literal on the wire. encodeURI leaves alone every character that is legal in a URL, so a comma, a colon, a slash, or an ampersand inside your error reason crosses untouched. If you build an error message from user input or from a string full of those characters, that is exactly the part that comes back raw, and anything downstream that parses the message assuming it was fully escaped will be wrong.

The one I would have missed without measuring it. In the handler I called the callback with an error object and got back exactly the code and message I asked for, fourteen and a short reason. But when the handler simply threw, the server caught it and sent code two, which is UNKNOWN, not thirteen which is INTERNAL, and the message became the literal string Unknown error with my exception text hidden. It names the thrown error only if the server process has the GRPC\_NODE\_DEBUG\_SEND\_ERROR\_DETAILS variable set to the string true in its environment. So an unhandled exception in a handler hands your client a code that means we do not know what this is and a message that means nothing, and nothing in the response tells you the throw even happened.

Two smaller things. Status codes are not checked against the zero to fifteen range the spec defines. I sent code sixteen and the client error came back with code sixteen, raw, and the name stayed a plain Error. The code is a number that rides the wire and reflects back, and nothing validates it against the known list. And the error is not only code plus message, because server supplied metadata rides along in it. I attached an x-retry-after value to the error and the client error object carried it in its metadata, so a server can hand a client a retry hint on the very same failure.

So a failed gRPC call is a 200 with an empty body and a verdict in the metadata, the message is half encoded, a bare throw becomes a useless UNKNOWN, and codes outside the range sail through unchecked. The [decode tab at proto.datajutsu.com](https://proto.datajutsu.com/?ref=datajutsu.com) reads the frame and the metadata the same way the client does, and the [request body post](https://datajutsu.com/build-grpc-request-body/?ref=datajutsu.com) is where the frame header is built. When a call fails, the bytes are not lying. They are just carrying the news in the header instead of the payload.