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

PromiseExtensions.Reject and InnerExceptions #1831

Closed
btpnlsl opened this issue May 10, 2018 · 6 comments
Closed

PromiseExtensions.Reject and InnerExceptions #1831

btpnlsl opened this issue May 10, 2018 · 6 comments
Labels

Comments

@btpnlsl
Copy link

btpnlsl commented May 10, 2018

I am looking into an error where LauncherModule.openURL is failing to open a URI because a native call to Launcher.LaunchUriAsync is throwing an exception for an unknown reason. Within openURL the exception is caught by a catch-block and the code is repackaging the exception within an InvalidOperationException before calling Promise.Reject.

In Promise.Reject (in PromiseExtensions.cs) the code is not pulling any info about the exceptions HResult or the InnerException, so all the information about why the native API failed is lost. I notice that this pattern of repackaging exceptions is used in a number of places.

At minimum RNW should not repackage exceptions if it is not providing the original exception information to Promise.Reject. Ideally RNW should also include HResult and InnerException in the Promise.Reject.

@rozele
Copy link
Collaborator

rozele commented May 18, 2018

@btpnlsl - there's an interesting trade-off here. Everything we include in the promise will be serialized to JavaScript, and we want to avoid serializing too much. At the same time, we want to be able to allow people to get as much detail out of the native exception as possible. Ideally, we'd have something like an Error module that allowed you to ask for additional details on an error from a rejected promise (i.e., we would serialize just top level information when the promise is initially rejected, and "pay for play" to serialize more details from the exception).

This would be tricky to implement, though, because there is no concept of a finalizer in JavaScript. We could handle this natively in Chakra via
https://github.com/Microsoft/ChakraCore/wiki/JsObjectBeforeCollectCallback, but for consistency with iOS and Android, we'd need to implement a similar feature for JSC.

@rozele
Copy link
Collaborator

rozele commented May 18, 2018

There is actually currently a similar issue w.r.t. the BlobModule in react-native, and how blobs are not being cleaned up after fetch requests. See facebook/react-native#19333

@rozele
Copy link
Collaborator

rozele commented May 18, 2018

@btpnlsl
Copy link
Author

btpnlsl commented May 22, 2018

@rozele We're already copying the exception's Data into userInfo. Why not just grab the InnerException as well? https://github.com/Microsoft/react-native-windows/blob/0a2dff3c939c14a253b23cb3d1194a0dbe7f4225/ReactWindows/ReactNative.Shared/Bridge/PromiseExtensions.cs#L76-L82

@rozele
Copy link
Collaborator

rozele commented Jul 23, 2018

We need to be careful about how much information we serialize across the bridge, it really should be a "pull" feature to get detailed information about the exception, rather than a push feature.

@rozele rozele added the .NET label Feb 26, 2019
@chrisglein chrisglein added the .NET Archive Issue opened against deprecated .NET implementation, will be closed (label drives bot activity) label Oct 25, 2019
@ghost
Copy link

ghost commented Oct 25, 2019

We are not investing in new features or lower priority bug fixes on vCurrent. The bulk of investment is now in vNext as we prepare to make that the default choice. If this issue is still relevant on the vNext implementation please open a vNext issue. If this issue is of significant severity for a vCurrent app and vNext is not an option, re-open with justification.

@ghost ghost removed the .NET Archive Issue opened against deprecated .NET implementation, will be closed (label drives bot activity) label Oct 25, 2019
@chrisglein chrisglein added the .NET Archive Issue opened against deprecated .NET implementation, will be closed (label drives bot activity) label Oct 25, 2019
@ghost ghost removed the .NET Archive Issue opened against deprecated .NET implementation, will be closed (label drives bot activity) label Oct 25, 2019
@ghost ghost closed this as completed Oct 25, 2019
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants