Repository navigation
test(voice): 冷启动转译挪到 beforeAll,node 用例不再被 15 秒计时器误杀 - #2461
Merged
Merged
Conversation
`node --import tsx src/cli.ts` 首次运行要转译 CLI 整个 import 图,缓存放在 TMPDIR 下;bun-test 腿给每个测试文件独立 TMPDIR,所以文件里第一次起 node CLI 总是冷缓存,耗时约为预热后的两倍,负载高时越过 cli() 的 15 秒计时器被 SIGKILL(#2460)。在 node 那组用例的 beforeAll 里先跑一次 `voice status` 付掉冷转译,计时的调用都从热缓存起步;计时器和用例超时都不变。 Co-Authored-By: Claude Opus 5.5 <[email protected]>
deepcoldy
requested review from
47seek,
LucasIcarus,
xiaoxueSunn and
xiongz-c
as code owners
October 28, 2026 02:13
This was referenced Oct 28, 2026
Owner
Author
|
已合入 52004ac(squash,标题带 #2461、正文为空)。合前复核:审过的 head 6f92d22 未变;期间 master 进了 #2217、#2452,都不碰本 PR 的文件,GitHub 判 MERGEABLE;落地树与「master ea956fa + 审过的 head」逐一相同;#2460 已随合入自动关闭。接下来把 master 同步进 #2457。 |
This was referenced Oct 28, 2026
|
🚀 Released in v3.55.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.
Closes #2460。
现象
PR #2457 的 bun-test 腿红在
test/cli-voice-setup.test.ts的第一条 node 用例(run 40613625981):CLI 刚打出第一个提示「选择 TTS 引擎」,就被测试 helpercli()自己的 15 秒计时器 SIGKILL。同一文件的其余用例都通过:紧接着的第二条(同样起两次 CLI)用了 12.4s,单次 CLI 的用例 2.6–4.7s。根因
node 那组用例用
node --import tsx src/cli.ts起 CLI。tsx 第一次运行要转译 CLI 的整个 import 图,结果缓存在 TMPDIR 下。bun-test 腿(scripts/run-bun-tests.mjs)给每个测试文件一个独立的 TMPDIR,所以这个文件里第一次起 node CLI 时总是冷缓存,之后的调用才是热的。isolate-run里实测node --import tsx src/cli.ts voice status,冷、热各三轮:冷缓存约为热缓存的两倍。CI 上同时跑 4 个文件,第一次调用就会越过 15 秒。vitest 腿各 worker 共用 runner 的 TMPDIR,缓存一直是热的,所以只在 bun-test 腿上出现。
修法
在 node 那组用例的
beforeAll里,用同样的隔离环境(临时 HOME / 配置,继承同一个 TMPDIR)先跑一次voice status,把冷转译付在 hook 里、不在任何计时器里;之后每次计时的调用都从热缓存起步。环境变量的拼装抽成cliEnv(dir),warm-up 与用例共用同一份。cli()的 15 秒计时器、各用例的超时都没改;它们照旧兜住真卡住的 CLI。bun 运行时那组不需要(同名用例 3.4s),warm-up 直接跳过。影响面
只改这一个测试文件,生产代码零改动。
验证
isolate-run,2 核 + 10 个空转进程,每轮新建 TMPDIR 模拟 bun-test 腿,bun test跑这条用例):CLI failed (null, SIGKILL));vitest跑该文件 +test-hygiene72 例全绿;bun test --timeout=180000跑该文件 46 例全绿。🤖 Generated with Claude Code