Skip to content

【Auto】Fix Upload: toggle visible 后受控 fileList 的 blob URL 失效(ERR_FILE_NOT_FOUND)#3130

Open
SudoUserReal wants to merge 1 commit intomainfrom
solve/issue-3122-1770116513425
Open

【Auto】Fix Upload: toggle visible 后受控 fileList 的 blob URL 失效(ERR_FILE_NOT_FOUND)#3130
SudoUserReal wants to merge 1 commit intomainfrom
solve/issue-3122-1770116513425

Conversation

@SudoUserReal
Copy link
Collaborator

关联 Issue: #3122([BUG] Upload component toggle visible file item blob ERR_FILE_NOT_FOUND)

问题概述

在受控 fileList 场景中,Upload 组件通过条件渲染(toggle visible)卸载/重挂载后,列表项里用于预览/展示的 blob: URL 会失效,浏览器报 ERR_FILE_NOT_FOUND,导致缩略图/预览异常。

根因是组件卸载时触发了 URL.revokeObjectURL 释放了仍被父组件保留并继续复用的 objectURL。

解决方案说明

将 objectURL 的释放时机从“组件卸载即统一释放”调整为“文件项真正从列表移除或 URL 被替换时再释放”,避免受控 fileList 在组件卸载期间持有的 blob: URL 被提前 revoke,同时仍确保在移除/清空等真实释放场景下回收内存。

主要变更点

  • 调整 UploadFoundation 的内存释放策略:不再在 destroy/unmount 阶段无条件 revoke 仍可能被外部复用的 objectURL(packages/semi-foundation/upload/foundation.ts
  • 在 UI/交互层面配合移除/清空等场景触发对应 URL 的释放,确保不引入明显的内存泄漏风险(packages/semi-ui/upload/index.tsx
  • 新增/更新回归测试:
    • 覆盖“受控 fileList + toggle visible”时不应 revoke objectURL
    • 覆盖“remove/clear”时应正确 revoke objectURL(packages/semi-ui/upload/__test__/upload.test.js

测试说明

…失效(ERR_FILE_NOT_FOUND)

This commit was automatically generated by Semi Issue Solver.
Closes #3122
@codesandbox-ci
Copy link

codesandbox-ci bot commented Feb 4, 2026

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 4b93a98:

Sandbox Source
pr-story Configuration

@cypress
Copy link

cypress bot commented Feb 4, 2026

semi-design    Run #3451

Run Properties:  status check passed Passed #3451  •  git commit 9e8f3455a6 ℹ️: Merge 4b93a98b7dd1de7b97dc767f918b045d2eb96991 into d56dc3df4f84819caa7e98a49e9d...
Project semi-design
Branch Review solve/issue-3122-1770116513425
Run status status check passed Passed #3451
Run duration 08m 10s
Commit git commit 9e8f3455a6 ℹ️: Merge 4b93a98b7dd1de7b97dc767f918b045d2eb96991 into d56dc3df4f84819caa7e98a49e9d...
Committer SudoUser
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 13
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 291
⚠️ You've recorded test results over your free plan limit.
Upgrade your plan to view test results.
View all changes introduced in this branch ↗︎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant