Status Codes are shown in incorrect alphabetical ordering
See original GitHub issueI don’t know why, but the StatusCode enums are in the wrong order.
That shows them sorted alphabetically, but they are not actually that way at all. The actual ordering:
StatusCode: {
OK: 0,
CANCELLED: 1,
UNKNOWN: 2,
INVALID_ARGUMENT: 3,
DEADLINE_EXCEEDED: 4,
NOT_FOUND: 5,
ALREADY_EXISTS: 6,
PERMISSION_DENIED: 7,
UNAUTHENTICATED: 16,
RESOURCE_EXHAUSTED: 8,
FAILED_PRECONDITION: 9,
ABORTED: 10,
OUT_OF_RANGE: 11,
UNIMPLEMENTED: 12,
INTERNAL: 13,
UNAVAILABLE: 14,
DATA_LOSS: 15
}
Issue Analytics
- State:
- Created a year ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Alphabetical error summary - Dialogic
Error name Hex Decimal
NFXERR_BAD_FILE_FORMAT 0x050207 328199
NFXERR_BAD_PAGE_SIZE 0x05020B 328203
NFXERR_BUFFER_UNDERRUN 0x050211 328209
Read more >Why Word's Alphabetical order is different from a dictionary
For alphabetical sorting upper and lower case letters are treated the same, despite having different ASCII values. The usual answer is wrong.
Read more >Python Alphabetical order by sort method shows wrong order
I am just learning python and I came across a code for sorting words alphabetically. My code is: my_str="Welcome to Python" words =...
Read more >ICD-10-CM Official Guidelines for Coding and Reporting - CMS
A code listed next to a main term in the ICD-10-CM Alphabetic Index is referred to as a default code. The default code...
Read more >Understanding MARC Bibliographic: Parts 7 to 10
The most common subfield codes used with each tag are shown. Each subfield code is ... Subfields $v, $x, $y, and $z do...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Oh wow thanks for the very detailed explanation! It’s very interesting to know! 😃
I’m not familiar with NextJS so maybe it’s somehow directly compile the TS enum into numbers (unlike the TS example we have, which pretty much generated the same JS code and was working fine for us.)
We’ll definitely keep this difference in mind going forward, and will be careful about future enums!
Thanks a lot for your report and code fix! 😃
Not a problem!
So I’m using NextJS and I’m not entirely sure how it compiles TS and if it does some weird stuff.
But essentially what was happening was I needed to check if the response was
NOT_FOUND
so I didrpcError.code == grpcWeb.StatusCode.NOT_FOUND
, and that was for sure causing errors during runtime.Because even though my server is sending the
NOT_FOUND
response which is error code5
,rpcError.Code
was actually interpreted asFAILED_PRECONDITION
which is error code5
. So during the check in theIF
statement,rpcError.code
is5
on the left side, then on the right sidegrpcWeb.StatusCode.NOT_FOUND
is actually8
so that condition was failing and my code was never executed even though it is expected to pass.But apart from the fact that my code was not working, I’m not 100% sure what the reason was, I do remember trying to
console.log
theif
condition and it showing5
and8
which is when I switched fromgrpcWeb.StatusCode.NOT_FOUND
to just5
like so:rpcError.code.valueOf() === 5
And it started working.