Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Perform safer checks for toContain(..) in example, and add NitroModules.hasNativeState(value) #324

Merged
merged 3 commits into from
Nov 12, 2024

Conversation

mrousavy
Copy link
Owner

@mrousavy mrousavy commented Nov 12, 2024

Adds a new API to NitroModules: NitroModules.hasNativeState(value).

With this API, we guard the toString() call of a HybridObject in release builds because we relied on an error being thrown, which turns into an assert (crash) in release.
To avoid relying on an error being thrown, we instead now somewhat safely check if we can stringify an object by checking if it has toString() or inherits from it - and then we check if it has NativeState. It is a fair assumption that toString() from prototype only works if we have NativeState, at least in the Nitro world.

Copy link

vercel bot commented Nov 12, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
nitro-docs ⬜️ Skipped (Inspect) Nov 12, 2024 5:05pm

@mrousavy mrousavy changed the title chore: Perform safer checks for toContain(..) in example fix: Perform safer checks for toContain(..) in example, and add NitroModules.hasNativeState(value) Nov 12, 2024
@mrousavy mrousavy merged commit c491d39 into main Nov 12, 2024
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Crash in android release mode during runtime in example app
1 participant