Repository navigation
fix(worker): Bun 下安装路径含中文或空格时 worker 启动报 preload not found - #3085
Merged
Merged
Conversation
worker fork 时把 worker-ipc-preload.js 以 file URL 传给 --import。Bun 不解码这里的 百分号编码,安装路径含中文、空格、%、# 时报 preload not found 直接退出,会话启动失败。 新增 preloadImportSpecifier:Bun 传原始绝对路径,Node 仍传 file URL(Node 会把原始路径里的 % / # 按 URL 解析)。workerForkExecArgv 改用它。独立二进制不经过 execArgv,不受影响。 Co-Authored-By: Claude Opus 5.5 <[email protected]>
deepcoldy
requested review from
47seek,
LucasIcarus,
xiaoxueSunn and
xiongz-c
as code owners
November 7, 2026 16:46
Owner
Author
Follow-up(非阻断,记录已知边界)本 PR 修复了安装路径含中文 / 空格 /
本 PR 的提交信息与 JSDoc 只声明覆盖 CJK / 空格 / (以上为自动评审过程中实测记录,最终以维护者审阅为准。) |
|
🚀 Released in v3.59.0 |
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.
现象
用 Bun 运行源码 / npm 安装的 botmux,安装路径含中文(反馈里是
~/Desktop/project/任务目录/…_diff命令/…)时,任何会话启动都失败:与具体 CLI 无关,worker 在预加载阶段就退出了。
根因
workerForkExecArgv()把worker-ipc-preload.js以pathToFileURL(...).href传给--import(v3.23.0 引入)。Bun(实测 1.4.4)不解码这里的百分号编码,路径里只要有会被编码的字符就找不到文件:%#改动
self-spawn.ts新增preloadImportSpecifier(path, bun):Bun 返回原始绝对路径,Node 仍返回 file URL。workerForkExecArgv()改用它。影响面
%/#:原来启动即失败,现在正常。bun build --compile):spawnWorker走自身重入分支,不使用execArgv,不受影响。测试
test/worker-preload-import-path.test.ts:任务目录/diff 命令#%41/dist下放预加载和入口文件,分别用真实bun/node以--import <preloadImportSpecifier(...)>启动,断言预加载先于入口执行(对应运行时不存在则跳过);workerForkExecArgv(true)给原始绝对路径,workerForkExecArgv(false)给指向同一文件的 file URL。bun test均通过。workerForkExecArgv忽略运行时 → 接线用例红。bun run build后把真实dist/worker-ipc-preload.js拷到与反馈同形的…/任务目录/20261029_botmux_diff命令/work/botmux-release/dist/下,fork 一个子进程并发worker_ipc_probe:Bun + 旧写法复现同样的preload not found退出 1;Bun + 新写法、Node 新旧写法都收到预加载回的worker_ipc_ready。bun run build、tsc --noEmit通过;worker-ipc-preload / session-lifecycle-start / cli-runner-compiled-entries / cli-subcommand-spawn-form / npm-binary-distribution 等相关 10 个文件 481 条全绿。🤖 Generated with Claude Code