Skip to content

fix(sdk): raise browser daemon bundle budget to 126 KiB - #5801

Merged
yiliang114 merged 2 commits into
QwenLM:mainfrom
wenshao:fix/daemon-sdk-bundle-budget
Jun 24, 2026
Merged

fix(sdk): raise browser daemon bundle budget to 126 KiB#5801
yiliang114 merged 2 commits into
QwenLM:mainfrom
wenshao:fix/daemon-sdk-bundle-budget

Conversation

@wenshao

@wenshao wenshao commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

Summary

main is red on the E2E Tests workflow — every job fails in Install dependencies at the SDK build step:

Error: Browser daemon SDK bundle is 128651 bytes; expected <= 128000
    at assertBrowserSafeBundle (packages/sdk-typescript/scripts/build.js:164)

Root cause

The browser-facing daemon SDK bundle has a hard size budget, MAX_DAEMON_BROWSER_BUNDLE_BYTES, currently 125 KiB (128000 bytes). The workspace permissions rules API (#5743) added workspacePermissions and the set/add/remove rule methods plus their types to DaemonClient (~718 bytes minified) but did not raise the budget. #5775 had just set the budget to 125 KiB while adding its own surface; #5743 was cut from an earlier base and stayed green on its own CI, so the two only combined over the budget once both landed on main. The bundle is now 128651 bytes — 651 over.

The voice-dictation merge (#5755) that the failing run points at did not touch sdk-typescript at all; it was simply the first push afterward to run the build and surface the pre-existing breakage.

Fix

Raise MAX_DAEMON_BROWSER_BUNDLE_BYTES one notch to 126 KiB (129024 bytes), following the established per-feature bump pattern documented in the same file. The permissions methods are public class methods on DaemonClient and are not tree-shakeable, so the bytes ship regardless of consumers — trimming is not an option without splitting the client.

Verification

  • Reproduced the failure locally (esbuild 0.25.12): the bundle builds to 128651 bytes, byte-identical to CI.
  • Isolated the cause: removing only the permissions API drops the bundle to 127933 bytes (under the old cap); an esbuild metafile confirms the delta is purely those methods and that unrelated branch diffs (e.g. src/types/types.ts) are not in the bundle.
  • With the raised cap, npm run build --workspace=packages/sdk-typescript passes (bundle 128651 ≤ 129024, 373 bytes headroom).
中文说明

概述

main 分支的 E2E Tests 工作流全部失败,每个 job 都在 Install dependencies 的 SDK 构建步骤报错:

Error: Browser daemon SDK bundle is 128651 bytes; expected <= 128000
    at assertBrowserSafeBundle (packages/sdk-typescript/scripts/build.js:164)

根因

面向浏览器的 daemon SDK bundle 有一个硬性体积上限 MAX_DAEMON_BROWSER_BUNDLE_BYTES,当前为 125 KiB(128000 字节)。workspace permissions rules API#5743)向 DaemonClient 新增了 workspacePermissions 以及 set/add/remove 规则方法和相关类型(压缩后约 718 字节),但没有同步上调上限。#5775 在加入自身代码时刚把上限设为 125 KiB;而 #5743 基于更早的分支,单独跑 CI 时是绿的,两者各自合入后在 main 上叠加才超出预算。当前 bundle 为 128651 字节,超出 651 字节。

报错那次构建指向的语音听写合并(#5755)根本没有改动 sdk-typescript,它只是之后第一个触发构建、从而暴露这个既有问题的 push。

修复

按文件中既有的「每个功能上调一档」惯例,将 MAX_DAEMON_BROWSER_BUNDLE_BYTES 上调一档到 126 KiB(129024 字节)。这些 permissions 方法是 DaemonClient 上的 public 类方法,无法被 tree-shaking 移除,无论是否有调用方都会进入 bundle —— 不拆分 client 就无法削减。

验证

  • 本地复现(esbuild 0.25.12):bundle 构建为 128651 字节,与 CI 完全一致。
  • 定位根因:仅移除 permissions API 后 bundle 降至 127933 字节(在旧上限之内);esbuild metafile 确认增量完全来自这些方法,且分支中无关的改动(如 src/types/types.ts)并不在 bundle 内。
  • 上调上限后,npm run build --workspace=packages/sdk-typescript 通过(bundle 128651 ≤ 129024,余量 373 字节)。

The workspace permissions rules API (QwenLM#5743) added workspacePermissions and
the set/add/remove rule methods plus their types to the browser-facing
DaemonClient (~718 bytes minified) without raising
MAX_DAEMON_BROWSER_BUNDLE_BYTES. On top of the 125 KiB budget set in QwenLM#5775,
the daemon SDK bundle grew to 128651 bytes and exceeded the 128000-byte cap,
breaking `npm run build` on main (E2E Tests fail at the bundle assertion).

These are public class methods on DaemonClient and are not tree-shakeable,
so the bytes ship regardless of consumers. Raise the cap one notch to 126 KiB
(129024 bytes), following the established per-feature bump pattern.
@qwen-code-ci-bot

Copy link
Copy Markdown
Collaborator

Thanks for the PR, @wenshao!

Template: the PR body doesn't follow the repo's PR template headings (missing "What this PR does", "Why it's needed", "Reviewer Test Plan", "Risk & Scope", "Linked Issues"). That said, the description is thorough and the change is trivially small — not blocking on template compliance for a one-line constant bump.

On direction: this is a clear CI fix — main is red because two independently-green PRs combined to push the bundle over budget. The fix (bumping the cap by 1 KiB) is the minimal, correct action. No CHANGELOG reference needed for an internal build-budget adjustment.

On approach: the change is exactly what's needed — 125 * 1024126 * 1024 with a comment following the established per-feature bump pattern. 373 bytes of headroom is tight, but trimming would require splitting the client, which is out of scope for an emergency CI fix. Moving on to code review. 🔍

中文说明

感谢 @wenshao 的 PR!

模板:PR 正文没有使用仓库的 PR 模板标题(缺少 "What this PR does"、"Why it's needed"、"Reviewer Test Plan"、"Risk & Scope"、"Linked Issues")。不过描述内容充分,且改动极小——对于一行常量的修改,不因模板问题阻塞。

方向:明确的 CI 修复——main 因为两个各自通过的 PR 合入后叠加超限而变红。修复方案(上调 1 KiB 上限)是最小且正确的做法。内部构建预算调整不需要 CHANGELOG 条目。

方案:改动恰到好处——125 * 1024126 * 1024,注释遵循既有的按功能上调惯例。373 字节余量偏紧,但缩减需要拆分 client,不适合作为紧急 CI 修复的范围。进入代码审查 🔍

Qwen Code · qwen3.7-max

@qwen-code-ci-bot

Copy link
Copy Markdown
Collaborator

Code Review

The diff is a textbook-minimal fix: one constant bump (125 * 1024126 * 1024) and one comment line following the established per-feature bump pattern in build.js. No bugs, no security concerns, no regressions. The comment accurately attributes the increase to the workspace permissions rules API from #5743.

My independent proposal before reading the diff: same approach — bump MAX_DAEMON_BROWSER_BUNDLE_BYTES by 1 KiB and add a bump-history comment. The PR matches exactly.

Reuse check: N/A — this is a constant adjustment, not logic.

Testing

This is a build-script constant change with no user-visible behavior — tmux real-scenario testing is not applicable. The CI environment doesn't have a fully bootstrapped SDK build pipeline, but the math is straightforward to verify:

  • Current bundle: 128,651 bytes
  • New cap: 126 × 1024 = 129,024 bytes
  • Headroom: 373 bytes ✓

The PR author independently reproduced the failure locally (esbuild 0.25.12, bundle = 128,651 bytes, byte-identical to CI) and confirmed the fix passes the build. Root cause analysis (isolating the permissions API delta via esbuild metafile) is thorough and convincing.

中文说明

代码审查

Diff 是最小化的标准修复:一处常量上调(125 * 1024126 * 1024)加一行注释,遵循 build.js 中既有的按功能上调注释惯例。无 bug、无安全隐患、无回归。注释准确地将增长归因于 #5743 引入的 workspace permissions rules API。

我在阅读 diff 之前的独立方案:同样的做法——上调 MAX_DAEMON_BROWSER_BUNDLE_BYTES 1 KiB 并添加历史记录注释。PR 方案完全一致。

复用检查:不适用——这是常量调整,非逻辑代码。

测试

这是构建脚本的常量修改,无用户可见行为——tmux 真实场景测试不适用。CI 环境没有完整的 SDK 构建流水线,但数学验证很简单:

  • 当前 bundle:128,651 字节
  • 新上限:126 × 1024 = 129,024 字节
  • 余量:373 字节 ✓

PR 作者独立在本地复现了故障(esbuild 0.25.12,bundle = 128,651 字节,与 CI 完全一致),并确认修复后构建通过。根因分析(通过 esbuild metafile 隔离 permissions API 增量)严谨且有说服力。

Qwen Code · qwen3.7-max

@qwen-code-ci-bot

Copy link
Copy Markdown
Collaborator

Stepping back: this is exactly the kind of fix you want to see when main is red — a clean, well-reasoned, minimal change with a thorough explanation.

The PR matches my independent proposal perfectly. The root cause analysis is more detailed than I'd expect for a one-line fix (esbuild metafile isolation, byte-identical local reproduction), which gives high confidence the diagnosis is correct. The fix does exactly what it says: bump the budget by 1 KiB following the established pattern.

The only minor note: the PR body doesn't follow the repo template, and the 373-byte headroom is tight — but neither is worth blocking. The next feature that touches the SDK bundle will likely need another bump regardless, and at that point someone should probably audit whether any dead surface can be trimmed rather than continuing to bump the cap.

Clean fix, ships what it promises, unblocks main. Approving. ✅

中文说明

退一步看:这正是 main 变红时希望看到的修复——干净、有理有据、最小化改动,附带详尽的说明。

PR 方案与我的独立方案完全一致。根因分析的深度超出一行修复的预期(esbuild metafile 隔离、本地字节级复现),令人高度确信诊断正确。修复做了它说要做的事:按既有惯例上调 1 KiB 预算。

唯一的小备注:PR 正文没有遵循仓库模板,373 字节余量偏紧——但都不值得阻塞。下一次涉及 SDK bundle 的功能添加时很可能需要再次上调上限,届时应该审计是否有废弃代码可以裁剪,而不是一直提高上限。

干净的修复,实现了承诺,解除了 main 阻塞。批准 ✅

Qwen Code · qwen3.7-max

@qwen-code-ci-bot qwen-code-ci-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, looks ready to ship. ✅

doudouOUC
doudouOUC previously approved these changes Jun 24, 2026

@doudouOUC doudouOUC left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM✅

@wenshao
wenshao enabled auto-merge (squash) June 24, 2026 05:57

@wenshao wenshao left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found. Downgraded from Approve to Comment: self-PR; CI still running. LGTM! ✅

— qwen3.7-max via Qwen Code /review

Resolve MAX_DAEMON_BROWSER_BUNDLE_BYTES conflict: keep both bump reasons
(workspace permissions API + prompt clientId self-heal). Both land in the
merged bundle (measured 129228 bytes), which exceeds 126 KiB, so the budget
must be 127 KiB.
@yiliang114
yiliang114 dismissed stale reviews from doudouOUC and qwen-code-ci-bot via 7248ab7 June 24, 2026 06:12

@yiliang114 yiliang114 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@doudouOUC doudouOUC left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM✅

@wenshao
wenshao disabled auto-merge June 24, 2026 06:26
@yiliang114
yiliang114 merged commit 4e0c636 into QwenLM:main Jun 24, 2026
22 checks passed
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.

4 participants