fix(uploads): resolve hash calculation memory crash and add hashing progress#375
fix(uploads): resolve hash calculation memory crash and add hashing progress#375xrgzs merged 3 commits intoOpenListTeam:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes a critical memory crash issue when calculating hashes for large files (10GB+) and adds progress reporting for the hashing phase. The changes address the "Array buffer allocation failed" error by introducing periodic yielding of the main thread during hash calculation.
Changes:
- Refactored hash calculation from recursive to iterative with periodic
setTimeout(0)calls to allow garbage collection - Added progress callback to
calculateHashfunction to report hashing progress - Introduced new "hashing" status with corresponding UI badge and translation
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/pages/home/uploads/util.ts | Refactored calculateHash to use while loop instead of recursion, added onProgress callback, and introduced setTimeout(0) every 10 iterations to yield control and enable GC |
| src/pages/home/uploads/types.ts | Added "hashing" status to Status union type and corresponding "warning" badge color to StatusBadge mapping |
| src/pages/home/uploads/stream.ts | Updated to set "hashing" status before hash calculation and pass progress callback to calculateHash |
| src/pages/home/uploads/form.ts | Updated to set "hashing" status before hash calculation and pass progress callback to calculateHash |
| src/lang/en/home.json | Added "hashing": "Hashing" translation string for the new status |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
已经改为Worker处理 |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: MadDogOwner <xiaoran@xrgzs.top>
Description / 描述
修复了大文件(10GB+)哈希计算导致的 Array buffer allocation failed 崩溃异常。
主要改进:
Motivation and Context / 背景
解决处理超大文件时主线程被长时间占用导致的页面假死和内存溢出崩溃,提升大文件上传的成功率与用户体验。
How Has This Been Tested? / 测试
Checklist / 检查清单
我已阅读 CONTRIBUTING 文档。
go fmtor prettier.我已使用
go fmt或 prettier 格式化提交的代码。我已为此 PR 添加了适当的标签(如无权限或需要的标签不存在,请在描述中说明,管理员将后续处理)。
我已在适当情况下使用"Request review"功能请求相关代码作者进行审查。
我已相应更新了相关仓库(若适用)。