`useRiveFile` does not handle errors thrown in RiveFile constructor
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
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from rive-app/rive-react
-
Difficulty 4/5 3-5 days Newbie friendliness 38/100
rive-app/rive-react#410 · 1 comment ·
-
enhancement
Difficulty 4/5 3-5 days Newbie friendliness 42/100
rive-app/rive-react#409 · 3 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 30/100
rive-app/rive-react#400 ·
-
triage
Difficulty 3/5 1-2 days Newbie friendliness 45/100
rive-app/rive-react#392 ·
-
triage
Difficulty 1/5 Under an hour Newbie friendliness 55/100
rive-app/rive-react#386 · 1 reaction ·
All issues in rive-app/rive-react
Similar issues
-
bug HemiStake
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
hemilabs/ui-monorepo#2413 ·
Maintainers usually reply within 1 day
-
component/ui framework/react kind/bug language/javascript
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
meshery/meshery#22216 · 3 comments ·
Maintainers usually reply within 1 day
-
type/bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
paperclipai/paperclip#14982 ·
Maintainers usually reply within 1 day
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficulty 1/5 Under an hour Newbie friendliness 95/100
lingdojo/kana-dojo#31515 · 1 comment · 5 reactions ·
Maintainers usually reply within 1 day