rive-app / rive-app/rive-react

How to catch wasm runtime loading error?

Open
#377 1 comment 0 reactions 0 assignees View on GitHub

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

Open the contributing guide

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.

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.