Skip to content

SEHException when handling promises inside CoreApplication dispatcher in React Native Module #12961

Open
@anacardix

Description

@anacardix

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

  1. Implement a React Native Module that handles promises and involves launching an application with Launcher.LaunchFileAsync.

  2. Use the following code snippet where the promise is resolved or rejected inside the CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync block:

    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

Metadata

Metadata

Assignees

Labels

Workstream: Module SupportModule developers have the requisite tooling and clear path for adding windows support to modules.bug

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions