Error during response serialization discards stack trace
Los mantenedores suelen responder en 2 días
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 65/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- grpc, nodejs, typescript
- Área
- api, backend, observability-sre
Línea de trabajo
The issue points to the server-interceptors.ts file, lines 892-901, where errors in responseSerialize are caught and only the message is used. Start by examining that catch block and the surrounding server error handling. The goal is to modify the error handling to log the full error (including stack trace) or provide a callback for users. Run the provided reproduction with the helloworld example to see the current behavior, then test any changes by ensuring errors are properly logged or exposed.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Problem description
When an error occurs during response serialization, i.e., the responseSerialize callback of the MethodDefinition throws, this section of code extracts the error message and discards the rest of the error:
https://github.com/grpc/grpc-node/blob/92ac80f7857a2345ef3265f50741812b74cbdf0a/packages/grpc-js/src/server-interceptors.ts#L892-L901
Since this only ever surfaces as an INTERNAL error on the client side, the server operator has no indication in their logs that anything might be wrong until a client complains.
Additionally, even if reported by a client, the error message may be of limited use without a stack trace. In our case, I ended up needing to attach a debugger to the server process and put a breakpoint in the above catch block to log the error object incl. stack trace to the console.
I propose logging such errors or exposing some other mechanism, e.g., a callback, for library users to react to them. For example, we have integrated Sentry reporting for exactly scenarios like this, and were very confused why nothing showed up there.
Reproduction steps
Apply the following patch to the helloworld example in this repo:
diff --git a/examples/helloworld/static_codegen/greeter_server.js b/examples/helloworld/static_codegen/greeter_server.js
index ae2ab949..66df1e6a 100644
--- a/examples/helloworld/static_codegen/greeter_server.js
+++ b/examples/helloworld/static_codegen/greeter_server.js
@@ -36,6 +36,11 @@ function sayHello(call, callback) {
*/
function main() {
var server = new grpc.Server();
+
+ services.GreeterService.sayHello.responseSerialize = () => {
+ throw new Error("oops");
+ };
+
server.addService(services.GreeterService, {sayHello: sayHello});
server.bindAsync('0.0.0.0:50051', grpc.ServerCredentials.createInsecure(), (err, port) => {
if (err != null) {
Then invoke the sayHello method any way you want.
Environment
- OS name, version and architecture: Debian Bookworm AArch64
- Node version: 24.18.1
- Node installation method: Docker Hub
library/node - Package name and version: @grpc/[email protected]
Additional context
No logs, which is the problem.
As for what led to this error: In our case, what happened was that bad data had ended up in a database row—a null in a PostgreSQL text[] column. This lead to generated serialization code attempting to call string(null) on a Writer object from protobufjs.
- Lenguaje dominante
- TypeScript
- Estrellas
- 4.8k
- Forks
- 716
- Merge medio
- 1 d 18 h
- PR fusionados (30 d)
- 17
Preparar el entorno
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de grpc/grpc-node
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 2 días
-
package: @grpc/grpc-js
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
grpc/grpc-node#2993 · 3 comentarios · 4 reacciones ·
Los mantenedores suelen responder en 2 días
-
feature request
Dificultad 3/5 1-2 días Aptitud para principiantes 68/100
grpc/grpc-node#3077 · 1 comentario ·
Los mantenedores suelen responder en 2 días
-
Dificultad 3/5 1-2 días Aptitud para principiantes 76/100
grpc/grpc-node#3068 · 2 comentarios · 1 reacción ·
Los mantenedores suelen responder en 2 días
-
Upgrade to protobufjs version 8Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 55/100
grpc/grpc-node#3062 · 2 comentarios · 1 reacción ·
Los mantenedores suelen responder en 2 días
Todos los issues de grpc/grpc-node
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
microsoft/vscode-livepreview#876 ·
Los mantenedores suelen responder en 1 día
-
needs-triage
Dificultad 1/5 Menos de una hora Aptitud para principiantes 90/100
JustJarethB/invoicer#54 ·
-
ICP 1.2.0 shows a scheduled task's interval in milliseconds under the label "Interval (In seconds)"AbiertoNeeds Triage Type/Bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
wso2/product-integrator#2585 ·
Los mantenedores suelen responder en 1 día
-
Add: Telemundo West sdAbiertocheck:passed streams:add
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día
-
design
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
MTES-MCT/monitor-field#119 ·
Los mantenedores suelen responder en 1 día