You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is about using big numbers with gRPC that overflow in Javascript and lead to corrupted values.
Some background on my problem
I have a gRPC API that uses Discord Snowflake IDs which are basically unsigned 64-bit integers. I know the Discord API docs already mention that they implement these IDs as strings to prevent overflows. I originally planned to only use my API with Python and Go, though, where this overflow for these values was not an issue, so I naively defined them as fixed64 in my proto files.
Now I wanted to build a little website around my service, which accesses the API via gRPC-web. Unfortunately, I now run into this exact issue of the IDs overflowing (at least that's what my very strong guess is where the problem seems to be) my service receiving false values. Passing them as strings into my proto messages doesn't get me any further either, since gRPC-web seems to convert them back to numbers, thus them overflowing again. I then tried to use BigInts, but that only lead to the internal conversion failing.
What I am hoping for
So I am not super familiar with Javascript and all it's quirks, but I wanted to ask if it might be possible for gRPC-web to either support the BigInt type or somehow handle numbers passed as strings differently, so that they don't get converted back and overflow. This is highly needed for services that use some bigger numbers, such as proto's int64, uint65, sint64, but mostly fixed64, since fixed64 is supposed to be used with values greater than 2^56 wich already overflow as normal Javascript numbers.
The text was updated successfully, but these errors were encountered:
Dealing with big numbers with gRPC
This is about using big numbers with gRPC that overflow in Javascript and lead to corrupted values.
Some background on my problem
I have a gRPC API that uses Discord Snowflake IDs which are basically unsigned 64-bit integers. I know the Discord API docs already mention that they implement these IDs as strings to prevent overflows. I originally planned to only use my API with Python and Go, though, where this overflow for these values was not an issue, so I naively defined them as
fixed64
in my proto files.Now I wanted to build a little website around my service, which accesses the API via gRPC-web. Unfortunately, I now run into this exact issue of the IDs overflowing (at least that's what my very strong guess is where the problem seems to be) my service receiving false values. Passing them as strings into my proto messages doesn't get me any further either, since gRPC-web seems to convert them back to numbers, thus them overflowing again. I then tried to use
BigInt
s, but that only lead to the internal conversion failing.What I am hoping for
So I am not super familiar with Javascript and all it's quirks, but I wanted to ask if it might be possible for gRPC-web to either support the
BigInt
type or somehow handle numbers passed as strings differently, so that they don't get converted back and overflow. This is highly needed for services that use some bigger numbers, such as proto'sint64
,uint65
,sint64
, but mostlyfixed64
, sincefixed64
is supposed to be used with values greater than 2^56 wich already overflow as normal Javascript numbers.The text was updated successfully, but these errors were encountered: