Skip to content

grpc-js: Log response serialization errors on the server - #3137

Merged
murgatroid99 merged 1 commit into
grpc:masterfrom
yeegz:fix/3091-log-serialization-error
Dec 1, 2026
Merged

murgatroid99 merged 1 commit into
grpc:masterfrom
yeegz:fix/3091-log-serialization-error

Conversation

@yeegz

@yeegz yeegz commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

Fixes #3091.

When a method's responseSerialize throws, BaseServerInterceptingCall.sendMessage catches the error and ends the call with INTERNAL. 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 ERROR verbosity, with the method path, before sending the status. The Error object is passed to the logger as is, so the default console.error logger prints its stack. A custom logger set with setLogger gets the same object.

Tests:

  • Added should log the serialization error with its stack trace to Server serialization failure handling in test/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 through serializeFail) and the method path. It fails on master ("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.
  • eslint reports nothing on the changed lines.

I used an AI coding assistant for this and reviewed it myself.

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
murgatroid99 merged commit d66661e into grpc:master Dec 1, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error during response serialization discards stack trace

3 participants