Repository navigation
grpc-js: map handler errors with code OK to UNKNOWN - #3130
Closed
Ayush701-code-zm wants to merge 1 commit into
Closed
Ayush701-code-zm wants to merge 1 commit into
Ayush701-code-zm wants to merge 1 commit into
Conversation
When a server handler passes an error object with code Status.OK (0) to its callback, sending it as-is would turn the error into a success status. This is contradictory and usually indicates an application bug. Previously, the client would receive OK with no message, which then resulted in UNIMPLEMENTED: No message received - hiding the actual error details. This fix maps such errors to Status.UNKNOWN while preserving the original details and metadata, matching the behavior of grpc-go (see grpc/grpc-go#6430). The fix applies to all handler types that use serverErrorToStatus: - Unary handlers (callback path) - Client streaming handlers (callback path) - Server streaming handlers (error event on writable stream) - Bidirectional streaming handlers (error event on duplex stream) Fixes: grpc#3124 Co-authored-by: Ayush701-code-zm <Ayush701-code-zm@users.noreply.github.com>
|
|
Member
|
The current behavior is correct. No fix is needed. |
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 #3124
If a server handler passes an error whose
codeisStatus.OK(for examplecb({ code: grpc.status.OK, details: '...' })),serverErrorToStatuscopied code 0, so the server ended the call with OK and no message. The client then reportedUNIMPLEMENTED: No message receivedand the original details were lost.This maps a truthy error with code OK to
Status.UNKNOWNand keeps the details and metadata, which matches grpc-go (grpc/grpc-go#6430). Errors with any other valid code behave as before.Since
serverErrorToStatusis shared, this covers unary and client streaming callbacks and theerrorevent on server streaming and bidi streams. Tests for all four are added intest/test-server-errors.ts.Tested with
npm run compileand the server test files in grpc-js (107 passing, 2 pending as before).