Skip to content

Bug: iOS Error: Unknown std::runtime_error when using react-native-skia #919

@kalem-edlin

Description

@kalem-edlin

What's happening?

Firstly, this project is awesome!

When @shopify/react-native-skia is added as a dependency and pods are installed, error messages from Swift/C++ native code are no longer propagated correctly to JavaScript. Instead of showing the actual error message, all errors show as "Error: Unknown std::runtime_error error."

I noticed this in my private Expo App (using Expo 53/React Native 0.79.5 initially and persisted in Expo 54/React Native 0.81.4) when none of my error contexts from my own Nitro Module usingRuntimeError.error(withMessage: [custom error message] were propagating to my JS code.

I have easily been able to reproduce this error by adding react-native-skia to the example app of this repo.

This issue was previously mentioned in #382, but that issue was closed. The problem still persists on the latest main branch. Without react-native-skia installed, all tests pass correctly and error messages propagate as expected.

It seems like there might be a conflict in how error handling works when multiple native modules using C++/JSI are present. The error messages are being stripped somewhere in the exception propagation chain when Skia is loaded.

Reproduceable Code

Pull Request

Relevant log output

❌ Test "funcThatThrows() throws" failed!
     Expected: "TestObjectCpp.funcThatThrows(...):"
     Got: "Error: `TestObjectCpp.funcThatThrows(...)` threw an unknown std::runtime_error error."

  ❌ Test "funcThatThrowsBeforePromise() throws" failed!
     Expected: "TestObjectCpp.funcThatThrowsBeforePromise(...):"
     Got: "Error: `TestObjectCpp.funcThatThrowsBeforePromise(...)` threw an unknown std::runtime_error
error."

  ❌ Test "set someVariant to false" failed!
     Expected: "Error: TestObjectCpp.someVariant: Cannot convert "false" to any type in
  variant<std::string, double>!"
     Got: "Error: `TestObjectCpp.someVariant` threw an unknown std::runtime_error error."

  ❌ Test "promiseThrows() throws" failed!
     Expected: "Error: Promise throws :)"
     Got: "Error: Unknown std::runtime_error error."

[... 9 total test failures with same pattern]

Device

iPhone 16 - iOS 18.3.1

Nitro Modules Version

0.29.8

Nitrogen Version

0.29.8

Can you reproduce this issue in the Nitro Example app here?

Yes, I can reproduce the same issue in the Example app here

Additional information

Metadata

Metadata

Assignees

No one assigned

    Labels

    nitro-coreIssue is related to the Nitro Modules core runtime/C++ codebase

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions