修复大脚本与资源的消息大小限制 - #1745
Open
cyfung1031 wants to merge 1 commit into
Open
修复大脚本与资源的消息大小限制#1745cyfung1031 wants to merge 1 commit into
cyfung1031 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Checklist / 检查清单
Description / 描述
背景
关联问题:Large scripts and resources can exceed Chrome’s 64 MiB extension-message limit。资源编辑器此前一次性返回所有资源,并同时传输文本与 Base64 表示;加上消息信封后,大脚本、资源集合以及其他跨上下文数据可能超过对应传输边界。
本次改动
实现考虑
消息大小按实际 JSON UTF-8 表示计算,structured-clone 通道另外计入 Blob、ArrayBuffer、DataView、Map 和 Set 中的二进制内容;边界测试覆盖 Unicode、JSON escaping、Base64、二进制值、精确上限和超限情形。资源块只允许资源关联脚本读取,并返回当前资源总字节数,客户端会校验 offset、length 和 total 后再组装下载 Blob。
已知限制
共享消息层的检查保护使用这些通道的现有调用方;它不会把任意业务数据改造成跨请求的通用存储协议。Chrome 64 MiB 限制、structured-clone 通道和 External Access WebSocket frame 限制分别处理,未将它们视为同一协议。未执行真实浏览器手工验证;自动化测试、类型检查、lint 和生产构建均已执行。
建议审查重点
关联
Closes #1744
验证
pnpm test:ci— 369 个测试文件通过,4738 个测试通过。pnpm run typecheck— 通过。pnpm run lint— Prettier、TypeScript、i18n、issue-template 和 ESLint 全部通过。pnpm run build— Rspack 生产构建通过;仅有仓库已有的 4 个 bundle/Monaco warning。Screenshots / 截图
N/A — 本次没有改变页面布局或视觉样式。