Repository navigation
test(sandbox): bwrap 身份/存储握手轮询等待内容而非文件存在,消除 CI flake - #1926
Merged
Merged
Conversation
容器内 cat > out / writeFileSync 都是先截断建文件、稍后字节才落地; 宿主侧用 existsSync 判就绪在 CI 高负载下会读到建文件与写入之间的空窗, cli-identity-bwrap 实测 flake(expected '' to contain 'token-second')。 两处真实 bwrap 握手改为轮询所需内容(刷新后的 token / 非空查询结果), 文件存在不再等价于内容就绪。 Co-Authored-By: Claude Code <[email protected]>
deepcoldy
requested review from
47seek,
LucasIcarus,
xiaoxueSunn and
xiongz-c
as code owners
October 14, 2026 12:48
|
🚀 Released in v3.44.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.
改了什么 / 为什么
合入 #833 后的 master push CI 出现一例真实 bwrap 用例 flake:
test/cli-identity-bwrap.test.ts > reads an atomically replaced identity through the production directory bind,现象expected '' to contain 'token-second'(同分片前一次运行该用例刚通过)。根因是测试握手的就绪判定,与被测生产代码无关:
cat identity > out(shell 重定向)——内核先截断/创建out,稍后才把字节写入;pollFor(() => existsSync(out))判「读完了」。文件「存在」不等于「内容已写完」,CI 高负载下 50ms 轮询正好落在「已建空文件、cat 尚未写入」的窗口,读到空串。修法(仅测试,零 src 改动):就绪判据从「文件存在」改为「所需内容就绪」。
cli-identity-bwrap.test.ts:轮询直到out含刷新后的token-second;读到旧token-first永不满足、按超时失败,不会假绿。test/session-store-bwrap.test.ts:同一 flake 形状(容器内writeFileSync('out', …)同样先建后写),轮询改为等out非空,最终 v2/ERR 断言不变。测试验证
: > out截断建空文件 → sleep 0.5s → 再写内容」:existsSync判据:确定性复现 CI 失败(expected '' to contain 'token-second');tsc0 错、bun run build通过。影响面:仅 2 个 linux-only、bwrap 可用才运行的测试文件;不改任何生产代码、其它 CLI/后端/平台不受影响。
🤖 Generated with Claude Code