Repository navigation
grpc-js: Log response serialization errors on the server - #3137
Merged
Merged
Conversation
When a method's responseSerialize throws, the server ends the call with INTERNAL and only the error message reaches the client. Nothing was logged on the server, so the failure and its stack trace were invisible to the server operator. Log the error with the method path at ERROR verbosity before sending the status. Fixes grpc#3091
murgatroid99
approved these changes
Dec 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3091.
When a method's
responseSerializethrows,BaseServerInterceptingCall.sendMessagecatches the error and ends the call withINTERNAL. Only the error message goes into the status details, and nothing is logged on the server. The server operator gets no sign of the failure, and the stack trace is lost.This change logs the error at
ERRORverbosity, with the method path, before sending the status. TheErrorobject is passed to the logger as is, so the defaultconsole.errorlogger prints its stack. A custom logger set withsetLoggergets the same object.Tests:
should log the serialization error with its stack tracetoServer serialization failure handlingintest/test-server-errors.ts. It sets a capturing logger, makes a unary call whose serializer throws, and checks that the logged arguments include the original error (message and a stack throughserializeFail) and the method path. It fails onmaster("the serialization error was not logged") and passes with the change.test-server-errors.js: 36 passing. The full grpc-js mocha suite gives 496 passing with the change and 495 without it. The same 8 TLS and credentials tests fail in my local environment (macOS arm64, Node 26) with and without the change.eslintreports nothing on the changed lines.I used an AI coding assistant for this and reviewed it myself.