Repository navigation
fix(compiled): zmx attach 与 zellij 探针在编译态下不再落到 help - #3058
Merged
Merged
Conversation
编译版单文件二进制把首个参数当子命令,<binary> <脚本路径> … 会打印 help 并 exit 0:zmx 本地 attach 没发生却报成功,findServerPid 恒为 null 导致 已有 zellij adopt 会话被关闭。 zmx attach 改用 resolveCliSpawn 生成 argv 并逐项引号;zellij 探针注册为隐藏 入口 __zellij-socket-probe,由 resolveEntrySpawn 启动,其直接执行判定在编译态 跳过。 Fixes #1120
deepcoldy
requested review from
47seek,
LucasIcarus,
xiaoxueSunn and
xiongz-c
as code owners
November 7, 2026 12:30
| // The socket owner must be another process: spawnSync below blocks this | ||
| // event loop, so a server here would never accept() the probe's connections. | ||
| const server = spawn(process.execPath, ['-e', | ||
| `require('node:net').createServer(c => c.on('error', () => {})).listen(${JSON.stringify(sock)}, () => console.log('ready'))`, |
This was referenced Nov 7, 2026
|
🚀 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.
Fixes #1120
只修 issue 列为该修的第 1、2 处(zmx attach 谎报成功、zellij adopt 静默丢会话);第 3、4 处 issue 已标为可延后(fail-closed),顺带的 connector-store flake 不在本 PR 范围。
现象
编译版单文件二进制把首个参数当子命令,
<binary> <脚本路径> …会打印 help 并 exit 0:exec <execPath> <cli.js> __zmx-attach-managed …,attach 没发生却返回成功;findServerPid用<execPath> <zellij-socket-probe.js> <sock> <pids>跑探针,拿到 help 文本Number()为 NaN,恒返回 null,已有 zellij adopt 会话被判为不存在而关闭。根因
这两处仍是 Node 形态的硬编码 argv,没有走
core/self-spawn.ts里已有的形态感知助手。修复
resolveCliSpawn(CLI_ENTRYPOINT, ['__zmx-attach-managed', …])生成 argv,再对每一项shellQuote。编译态不再拼脚本路径,也就不会把/$bunfs/…交给 shell 展开;Node 形态命令不变(仅子命令 token 也加了引号)。__zellij-socket-probe(BotmuxEntry+cli.ts分发),findServerPid改用resolveEntrySpawn('zellij-socket-probe', distDir);Node 形态仍执行同一个dist/adapters/backend/zellij-socket-probe.js。探针模块的「直接执行」判定在编译态跳过:编译产物里所有模块共用二进制的 URL,该判定对任何 import 都成立,会用错位的参数再跑一份探针并 exit 1(真机二进制实测发现)。验证
process.argv[1] = '/$bunfs/…'走真实的isStandaloneBinary()分支):test/local-cli-opener.test.ts:编译态 zmx attach 为exec '<execPath>' '__zmx-attach-managed' …,不含cli.js/$bunfstest/zellij-server-pid-compiled.test.ts:编译态findServerPid以<execPath> __zellij-socket-probe <sock> <pids>启动探针;Node 形态仍是探针脚本test/zellij-backend-helpers.test.ts:经src/cli.ts真实分发__zellij-socket-probe,对另一个进程监听的 unix socket 归因出该进程 pid;缺参 exit 64findServerPid恢复脚本路径;去掉cli.ts分发分支;分发参数错位;zmx 恢复脚本路径;去掉逐项引号。scripts/build-bun-binary.mjs,临时 HOME):<binary> <probe.js> <sock> <pid>→ help + exit 0(Number(stdout)=NaN);新形态<binary> __zellij-socket-probe <sock> <pid>→ exit 0,输出监听进程 pid<binary> //root/cli.js __zmx-attach-managed …→ help + exit 0;新形态<binary> __zmx-attach-managed …→ 进入真实 helper,对不存在的会话拒绝 attach(exit 1)tsc --noEmit、npm run build通过;相关 6 个测试文件 vitest 104/104 通过;bun 腿中zellij-backend-helpers、local-cli-opener等通过,zellij-server-pid-compiled与既有的card-handler-open-local-cli使用importOriginal,按bun-leg-selectors不在 bun 腿运行。