-
Notifications
You must be signed in to change notification settings - Fork 124
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
Runtime TypeError getBigUint64 is not a function using Safari 14 #24
Comments
Hi Patrick, unfortunately, BigInt can't be used in browsers because of Safari :-/ protobuf-ts supports two alternatives to the BigInt representation: JavaScript For arithmetics across browsers, you need a 3rd party lib. JSBI, or long.js. // using long.js:
let a = Long.fromString(myMessage.int64Field)
let b = a.add(123);
myMessage.int64Field = b.toString();
// JSBI, very similar:
let a = JSBI.BigInt(myMessage.int64Field)
let b = a.add(123);
myMessage.int64Field = b.toString(); It thought about supporting JSBI as a representation and decided against, mostly because it would add a dependency to the runtime (at the moment, it has no deps at all). Anyways, the error message in Safari should be improved! What about:
Would this have helped you to find / fix the problem? Not sure about Safari 13... my Version 13.1 (14609.1.20.111.8) shows the same type error when trying to call |
Hey @timostamm, Using your suggested workaround long_type_string does not seem to work. The proto compiler does indeed replace all BigInts with string types but the error persists. Apparently it is thown by runtime-rpc:68/grpc-web-transport:142. Using long_type_number seems to work..... |
Hmm I have the Here are the options I a using from my build script.
Appreciate the prompt reply! |
Using |
Ok, this sounds like there is some code path that calls A stack trace would be super helpful. @pzeinlinger, are you on Safari 14 as well? I'll do an update to Safari 14 and try to get this reproduced... |
Yes I am. Tried it on an iPad as well as Catalina.
…On Thu, Nov 12, 2020, 23:20 Timo Stamm ***@***.***> wrote:
Ok, this sounds like there is some code path that calls PbUlong.toBigInt(),
even though code is generated for string representation.
A stack trace would be super helpful.
@pzeinlinger <https://github.com/pzeinlinger>, are you on Safari 14 as
well?
I'll do an update to Safari 14 and try to get this reproduced...
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#24 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AGJCHS44W2IXKR6SNEYTOQ3SPRNSBANCNFSM4TTTYEVA>
.
|
protobuf-ts/packages/runtime/src/pb-long.ts Line 149 in 7286616
Checking in console:
It looks like BigInt was added into Safari 14 https://developer.apple.com/documentation/safari-release-notes/safari-14-release-notes Confirmed that |
Thank you both for the details! This is fixed in release v1.0.8. Safari 14 adds the BigInt constructor function, but it does not implement the DataView BigInt methods. The fixed code if all necessary BigInt features are present. When running bigint code in Safari, the following error is raised: |
Thanks @timostamm!! Appreciate it! |
Hi @timostamm, I have recently updated to Safari 14 and noticed the following error in my application which appears to be coming from the runtime.
protobuf-ts/packages/runtime/src/pb-long.ts
Line 159 in 7286616
Surprisingly, I didnt see this error in Safari 13, despite this method apparently not being supported. Im guessing the error was silently ignored?
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView#Browser_compatibility
I did find some discussion on this topic already and it looks like it wouldnt be too bad to write a polyfill using JSBI.
System information
10.15.7
Version 14.0 (15610.1.28.1.9, 15610)
Let me know if there is any other information I can provide! Thanks again for putting together this project!
The text was updated successfully, but these errors were encountered: