microsoft / microsoft/react-native-windows
SEHException when handling promises inside CoreApplication dispatcher in React Native Module
@vmoroz is already working on this.
Since Aug 14, 2024.
- Dominant language
- C++
- Stars
- 17.3k
- Forks
- 1.2k
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 33
Description
Problem Description
When handling promises within a React Native Module, specifically using the CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync method to launch an application, a System.Runtime.InteropServices.SEHException labeled "External component has thrown an exception." is thrown. This occurs at the method WriteArgs of JSValueWriter. However, moving the promise resolution outside of the CoreApplication block resolves the issue.
Steps to Reproduce
-
Implement a React Native Module that handles promises and involves launching an application with
Launcher.LaunchFileAsync. -
Use the following code snippet where the promise is resolved or rejected inside the
CoreApplication.MainView.CoreWindow.Dispatcher.RunAsyncblock:await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync( CoreDispatcherPriority.Normal, async () => { var success = await Launcher.LaunchFileAsync(fileToLaunch); if (!success) { promise.Reject(new ReactError { Code = "ERR_LAUNCH_FAILED", Message = "Unable to launch application." }); } else { promise.Resolve(); } });
Steps To Reproduce
Run the above code
Expected Results
No response
CLI version
12.3.2
Environment
System:
OS: Windows 10 10.0.19045
CPU: (4) x64 Intel(R) Xeon(R) Gold 6238 CPU @ 2.10GHz
Memory: 6.48 GB / 16.00 GB
Binaries:
Node:
version: 20.11.1
path: C:\Program Files\nodejs\node.EXE
Yarn:
version: 1.22.21
path: ~\AppData\Roaming\npm\yarn.CMD
npm:
version: 10.4.0
path: C:\Program Files\nodejs\npm.CMD
Watchman: Not Found
SDKs:
Android SDK: Not Found
Windows SDK:
AllowDevelopmentWithoutDevLicense: Enabled
AllowAllTrustedApps: Enabled
Versions:
- 10.0.10586.0
- 10.0.19041.0
- 10.0.20348.0
- 10.0.22621.0
IDEs:
Android Studio: Not Found
Visual Studio:
- 16.11.34601.136 (Visual Studio Enterprise 2019)
- 17.9.34728.123 (Visual Studio Enterprise 2022)
Languages:
Java: Not Found
Ruby: Not Found
npmPackages:
"@react-native-community/cli": Not Found
react:
installed: 18.2.0
wanted: 18.2.0
react-native:
installed: 0.73.4
wanted: 0.73.4
react-native-windows:
installed: 0.73.5
wanted: 0.73.5
npmGlobalPackages:
"*react-native*": Not Found
Android:
hermesEnabled: Not found
newArchEnabled: Not found
iOS:
hermesEnabled: Not found
newArchEnabled: Not found
Target Platform Version
10.0.19041
Target Device(s)
Desktop
Visual Studio Version
Visual Studio 2022
Build Configuration
Debug
Snack, code example, screenshot, or link to a repository
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.