rive-app / rive-app/rive-react
How to catch wasm runtime loading error?
Open
Nobody has claimed this yet.
triage
- Dominant language
- TypeScript
- Stars
- 1.2k
- Forks
- 58
- Avg merge
- 3h 23m
- Merged PRs (30d)
- 6
Description
Let's say there's no network connection while loading rive.wasm, how do I able to know there's an error loading wasm?
window.onerror = () => {
// won't catch wasm loading error
}
window.onunhandledrejection = () => {
// won't catch wasm loading error
}
const loadingRiveFile = (async () => {
const file = new RiveFile({ src: '...' })
try {
await file.init()
} catch {
// won't catch wasm loading error
}
return file
})()
function MyComponent() {
const riveFile = use(loadingRiveFile)
const { RiveComponent } = useRive({
riveFile,
onLoadError: () => {
// won't catch wasm loading error
}
})
return (
// ...
)
}
function App() {
return (
<Suspense fallback={'loading...'}>
<MyComponent />
</Suspense>
)
}
Contributor 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.
Research direction
Start by tracing RiveFile initialization through file.init(), then compare its failure path with useRive's onLoadError and the window error handlers shown in the report. Determine where a failed rive.wasm load is surfaced and verify that the loading failure reaches a documented catch or error callback while the Suspense example behaves predictably.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100