Skip to content

Android native module rejections are not instanceof Error #44050

@vonovak

Description

@vonovak

Description

Promise rejections coming from native modules on Android are not instanceof Error. This is not in line with iOS, and with what is expected.

This is the same as #41950 but for Android - I'm not sure if I made a mistake back then when I reported it for iOS only, or if something has changed... but I'm reporting it now. It's also present on the main branch.

An (somewhat poor) attempt at a fix is at #44051

Steps to reproduce

Linking.openURL('sfslfjsd').catch(e => {
  console.warn({isInstanceOf: e instanceof Error, errorToString: e.toString()});
});

the output is {"errorToString": "[object Object]", "isInstanceOf": false}

React Native Version

0.74.0-rc.8

Affected Platforms

Runtime - Android

Areas

TurboModule - The New Native Module System

Output of npx react-native info

System:
  OS: macOS 14.4.1
  CPU: (10) arm64 Apple M1 Max
  Memory: 178.20 MB / 64.00 GB
  Shell:
    version: 5.2.15
    path: /opt/homebrew/bin/bash
Binaries:
  Node:
    version: 21.7.1
    path: /opt/homebrew/bin/node
  Yarn:
    version: 1.22.22
    path: /opt/homebrew/bin/yarn
  npm:
    version: 10.5.0
    path: /opt/homebrew/bin/npm
  Watchman:
    version: 2024.03.25.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.15.2
    path: /opt/homebrew/lib/ruby/gems/2.7.0/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.4
      - iOS 17.4
      - macOS 14.4
      - tvOS 17.4
      - visionOS 1.1
      - watchOS 10.4
  Android SDK:
    API Levels:
      - "24"
      - "28"
      - "29"
      - "30"
      - "33"
      - "33"
      - "33"
      - "34"
    Build Tools:
      - 28.0.3
      - 29.0.2
      - 30.0.2
      - 30.0.3
      - 31.0.0
      - 32.0.0
      - 33.0.0
      - 33.0.1
      - 34.0.0
    System Images:
      - android-23 | Intel x86 Atom
      - android-23 | Google APIs ARM 64 v8a
      - android-23 | Google APIs ARM EABI v7a
      - android-24 | ARM 64 v8a
      - android-24 | Google APIs ARM 64 v8a
      - android-24 | Google Play Intel x86 Atom
      - android-25 | Google APIs ARM 64 v8a
      - android-26 | ARM 64 v8a
      - android-28 | ARM 64 v8a
      - android-29 | Google APIs ARM 64 v8a
      - android-30 | Google Play ARM 64 v8a
      - android-34 | Google APIs ARM 64 v8a
    Android NDK: 22.1.7171670
IDEs:
  Android Studio: Not Found
  Xcode:
    version: 15.3/15E204a
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.9
    path: /usr/bin/javac
  Ruby:
    version: 2.7.8
    path: /opt/homebrew/opt/[email protected]/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.74.0-rc.8
    wanted: 0.74.0-rc.8
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: true
  newArchEnabled: true

Stacktrace or Logs

none

Reproducer

https://github.com/vonovak/bugrepro

Screenshots and Videos

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Platform: AndroidAndroid applications.Resolution: FixedA PR that fixes this issue has been merged.Type: New ArchitectureIssues and PRs related to new architecture (Fabric/Turbo Modules)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions