Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

`useRiveFile` does not handle errors thrown in RiveFile constructor

未关闭
#267 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
45/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
react, typescript
领域
frontend

调研方向

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.

由索引模型根据 Issue 内容生成。

描述

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!

主要语言
TypeScript
星标
1.2k
派生
58
平均合并
52 分钟
30 天内合并 PR
4

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

rive-app/rive-react 的其他 Issue

查看 rive-app/rive-react 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。