OpenNative / open-native

Open Native brings cross-platform communities together to help them collaborate and strengthen each other through development diversity.
https://open-native.org/
MIT License
449 stars 7 forks source link

[bug] Unable to marshal native value to JS #15

Closed NathanWalker closed 1 year ago

NathanWalker commented 1 year ago

Using react-native-auth0 2.17.0 as example case, appears NSError is not properly handled. Might be better to use @nativescript/core 8.4+ Utils.dataDeserialize(data) instead of custom handling there. The throw is likely unnecessary on this line - rather can just return the data object "as-is" which is what core Utils does in this case.

  NativeScript encountered a fatal error: Uncaught Error: Unable to marshal native value to JS: NSError:Error Domain=com.apple.AuthenticationServices.WebAuthenticationSession Code=2 "Cannot start ASWebAuthenticationSession without providing presentation context. Set presentationContextProvider before calling -start." UserInfo={NSDebugDescription=Cannot start ASWebAuthenticationSession without providing presentation context. Set presentationContextProvider before calling -start.}
  at
  toJSValue(file: src/webpack:/node_modules/@open-native/core/src/ios/converter.js:325:10)
  at toJSValue(file: src/webpack:/node_modules/@open-native/core/src/ios/converter.js:305:23)
ammarahm-ed commented 1 year ago

Good catch! I will take a look and handle this properly. Seems like we are not handling NSError inside toJSValue converter so it just skips it and gives an error. Ideally we should rely on core to marshal any value we can't on our own.

ammarahm-ed commented 1 year ago

Fixed in 1.0.0-alpha.23.