Repository navigation
fix(test): detached restart 用例等待完整 JSON 而非文件出现 - #2838
Merged
Merged
Conversation
bun-test 在 CI 高负载下偶发红:等待循环只判 driver.json 存在(最多 1s), 而 writeFileSync 先以 O_TRUNC 建空文件再写内容,detached 驱动链 (CLI→driver)在忙 runner 上启动超过 1s 时,循环在空文件窗口退出, JSON.parse 读到空文件报 Unexpected EOF。 改为轮询直到内容可完整解析(上限 10s),内容未就绪继续等。本地 bun 连跑 10 轮、vitest 43/43 绿;变异探针(先建空文件、150ms 后写内容)证实旧等待 读到 EOF、新等待拿到内容。 Co-Authored-By: Claude Code <[email protected]>
deepcoldy
requested review from
47seek,
LucasIcarus,
xiaoxueSunn and
xiongz-c
as code owners
November 5, 2026 08:40
This was referenced Nov 5, 2026
|
🚀 Released in v3.57.2 |
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.
背景
#2831 首跑 bun-test 唯一红灯:test/maintenance.test.ts 的 spawnDetachedRestart > passes the restart lease to the actual detached CLI driver,报
SyntaxError: JSON Parse error: Unexpected EOF(2005 个文件中仅此 1 个失败)。根因
等待循环只判
driver.json存在(50 × 20ms = 1s):detached 驱动链(CLI → driver)在高负载 runner 上启动可超过 1s;而
writeFileSync先以 O_TRUNC 创建空文件、随后才写入内容。循环在「空文件窗口」退出,读到空文件 → EOF。#2831 与该文件零交集,是公共时序 flake 这次在该 PR 上咬红。修改
轮询直到文件内容可被 JSON 完整解析(上限 10s),内容未就绪继续等;不再用文件存在作为完成条件。仅测试文件,无产品行为变化。
验证
合入后 #2831 同步 master、新 head 首跑全绿再走合码(merge-standard G4:跑过 step 的 flake 根治后转绿,不同 SHA 重跑)。
🤖 Generated with Claude Code