Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated javascript example #576

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ShahanaFarooqui
Copy link
Collaborator

Fixed bug due to encodeDelimited function.

Fixed bug due to encodeDelimited function.
@ShahanaFarooqui ShahanaFarooqui force-pushed the grpc-web-proxy-client-example branch from 5b5528d to b79af42 Compare February 14, 2025 05:59
@cdecker cdecker enabled auto-merge (rebase) March 4, 2025 09:35
@cdecker cdecker disabled auto-merge March 11, 2025 15:17
@cdecker
Copy link
Collaborator

cdecker commented Mar 11, 2025

I think you might be mixing grpc-status defined here, and HTTP status codes. Can you ensure that you are using the right number range for the header grpc-status?

@ShahanaFarooqui
Copy link
Collaborator Author

I think you might be mixing grpc-status defined here, and HTTP status codes. Can you ensure that you are using the right number range for the header grpc-status?

I got them mixed up in my initial commit but fixed them later. I am now decoding the grpc-status in method getGrpcErrorMessage .

function getGrpcErrorMessage(grpcStatusCode) {
const grpcStatusMessages = {
0: 'OK: The operation completed successfully.',
1: 'CANCELLED: The operation was cancelled (typically by the caller).',
2: 'UNKNOWN: Unknown error. Usually means an internal error occurred.',
3: 'INVALID_ARGUMENT: The client specified an invalid argument.',
4: 'DEADLINE_EXCEEDED: The operation took too long and exceeded the time limit.',
5: 'NOT_FOUND: A specified resource was not found.',
6: 'ALREADY_EXISTS: The resource already exists.',
7: 'PERMISSION_DENIED: The caller does not have permission to execute the operation.',
8: 'RESOURCE_EXHAUSTED: A resource (such as quota) was exhausted.',
9: 'FAILED_PRECONDITION: The operation was rejected due to a failed precondition.',
10: 'ABORTED: The operation was aborted, typically due to a concurrency issue.',
11: 'OUT_OF_RANGE: The operation attempted to access an out-of-range value.',
12: 'UNIMPLEMENTED: The operation is not implemented or supported by the server.',
13: 'INTERNAL: Internal server error.',
14: 'UNAVAILABLE: The service is unavailable (e.g., network issues, server down).',
15: 'DATA_LOSS: Unrecoverable data loss or corruption.',
16: 'UNAUTHENTICATED: The request is missing or has invalid authentication credentials.'
}
return grpcStatusMessages[grpcStatusCode] || "UNKNOWN_STATUS_CODE: The status code returned by gRPC server is not in the list.";
}

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.

2 participants