Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

`useRiveFile` does not handle errors thrown in RiveFile constructor

Open
#267 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
react, typescript
Domain
frontend

Research direction

Start at the useRiveFile hook and compare its error path with the try/catch around new RiveFile in js/src/rive.ts at lines 1817-1824. Review the RiveFile initData path around lines 1453-1457 and verify that a loading failure produces the hook's failed status without an uncaught error crashing the app.

Written by the indexing model from the issue text.

Description

I want to use the status returned by the useRiveFile hook to fail gracefully if there is an error while loading the file, e.g. if the file at src is missing.

Currently, if there is an error during the initData method of RiveFile, firing the loadError event is immediately followed by throwing an Error (https://github.com/rive-app/rive-wasm/blob/55691eb4893e3056f2d5096fbc3f2e58142e8d79/js/src/rive.ts#L1453-L1457).

This makes the status returned by useRiveFile provide little value for this use case, since if status === 'failed', the app is going to crash anyways.

This is not an issue when using useRive without useRiveFile, because the call to new RiveFile is wrapped in a try / catch in the Rive constructor (https://github.com/rive-app/rive-wasm/blob/55691eb4893e3056f2d5096fbc3f2e58142e8d79/js/src/rive.ts#L1817-L1824).

I think similarly, useRiveFile should also catch errors thrown by new RiveFile. Without this error handling, I don't think I can use useRiveFile in production.

Other work-arounds also welcome!

Thank you!

Dominant language
TypeScript
Stars
1.2k
Forks
58
Avg merge
3h 26m
Merged PRs (30d)
6

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from rive-app/rive-react

All issues in rive-app/rive-react

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.