Error during response serialization discards stack trace
メンテナーはふだん 2 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 65/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- grpc, nodejs, typescript
- 領域
- api, backend, observability-sre
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- TypeScript
- スター
- 4.8k
- フォーク
- 717
- 平均マージ
- 1日 18時間
- マージ済み PR(30日)
- 17
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
grpc/grpc-node のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 2 日以内に返信
-
package: @grpc/grpc-js
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
grpc/grpc-node#2993 · コメント 3 件 · リアクション 4 件 ·
メンテナーはふだん 2 日以内に返信
-
feature request
難易度 3/5 1〜2日 初心者へのやさしさ 68/100
grpc/grpc-node#3077 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
-
難易度 3/5 1〜2日 初心者へのやさしさ 76/100
grpc/grpc-node#3068 · コメント 2 件 · リアクション 1 件 ·
メンテナーはふだん 2 日以内に返信
-
難易度 3/5 1〜2日 初心者へのやさしさ 55/100
grpc/grpc-node#3062 · コメント 2 件 · リアクション 1 件 ·
メンテナーはふだん 2 日以内に返信
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
callstackincubator/rozenite#518 ·
メンテナーはふだん 1 日以内に返信
-
Area/Workflow Priority/Blocker Type/Bug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
wso2/product-integrator#2622 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
-
area:bash bug has repro platform:macos
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
anthropics/claude-code#98644 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
allure-framework/allure-js#1603 ·
メンテナーはふだん 1 日以内に返信