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: await file init in useRiveFile to catch async errors #270

Closed
wants to merge 2 commits into from

Conversation

petersli
Copy link

@petersli petersli commented Jun 26, 2024

@damzobridge @bodymovin

When testing out #269, I realized that the errors thrown by file.init() were not actually being caught by the try/catch due to init being async.

In the rive-wasm repo, in order to catch the errors thrown within the async init of the file, they use await (https://github.com/rive-app/rive-wasm/blob/6d5cd8909a635184f156be03d1f32d5ceb4025fc/js/src/rive.ts#L1739).

Testing locally, this fixes my issue!

Before:
The app still crashes if I pass a bad src to useRiveFile.

After:
If there's a bad src, the app does not crash anymore. If the src is valid, the Rive file loads and the animation plays as expected.

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.

1 participant