Skip to content

Errors on Android don't have a message: Unknown std::runtime_error error #382

Description

@mrousavy

What's happening?

On Android, errors / exceptions don't have a proper message, and always resort to Unknown T error (e.g. Unknown std::runtime_error error) instead of using it's message (what()).

The same goes for Promise<T>.

I can't really figure out why this is happening - my best guess is that there is some ABI issue with the libc++ standard used by Android NDK, and since errors in Nitro are implemented using std::exception_ptr, the methods current_exception()/rethrow_exception(..) are broken in Android.
I created an issue in the react-native repo: react/react-native#48027

Reproduceable Code

class MyHybrid: public MyHybridSpec {
  // ...
public:
  void someFunc() override {
    throw std::runtime_error("my message!");
  }
};

Relevant log output

iOS ✅:

MyHybrid.someFunc(): my message!

Android ❌:

MyHybrid.someFunc() threw an unknown std::runtime_error error.

Device

Huawei P10

Nitro Modules Version

0.18.1

Nitrogen Version

0.18.1

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions