-
Notifications
You must be signed in to change notification settings - Fork 3k
fix(ci): yield the event loop between script tests to avoid vitest RPC timeouts (#10037) #10050
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+38
−1
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
b5c6199
fix(ci): yield the event loop between script tests to avoid vitest RP…
qwen-code-dev-bot 17ba8c6
fix(ci): state the actual yield invariant in the script test setup co…
qwen-code-dev-bot 9ad92bd
test(ci): pin the script-test event-loop yield invariant (#10037)
qwen-code-dev-bot 0b76a2b
Merge branch 'main' into autofix/issue-10037
wenshao File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| /** | ||
| * @license | ||
| * Copyright 2026 Qwen Team | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| import { expect, it } from 'vitest'; | ||
|
|
||
| // Pins the invariant established by test-setup.ts's beforeEach yield: | ||
| // between two tests the worker's event loop must turn far enough to drain | ||
| // pending macrotasks. Without that yield a fully synchronous file never | ||
| // reaches the timer phase between tests, the flag armed below never flips, | ||
| // and the same unbroken stall is what lets vitest's fixed 60s worker->main | ||
| // `onTaskUpdate` RPC timeout fire (see test-setup.ts). | ||
| let macrotaskRan = false; | ||
|
|
||
| it('arms a flag from a real macrotask callback', () => { | ||
| setTimeout(() => { | ||
| macrotaskRan = true; | ||
| }, 0); | ||
| }); | ||
|
|
||
| it('observes the event loop turned between tests', () => { | ||
| expect(macrotaskRan).toBe(true); | ||
| }); |
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Suggestion] No automated test pins the yield invariant this hook establishes. The reviewer test plan performs the mutation check manually ("delete the
beforeEachyield … the failure must come back"), so once this PR merges, nothing in CI stops a future edit from silently removing the yield: a cleanup refactor, a restructuring intoglobalSetup, or a vitest upgrade that changes setup-file hook semantics could remove or neutralise the hook with no test failing. The regression would first surface at the next release, when a long synchronous script suite (the autofix-workflow suite alone stalls ~66s) re-triggers vitest's fixed 60sonTaskUpdateRPC timeout — the exact v0.22.1 release failure this PR fixes (exit 1 with every test green on the Linux release lane; silently swallowed on the non-Linux lanes bydangerouslyIgnoreUnhandledErrors).Verified by probe (vitest 3.2.7 in an isolated scratch tree, this repo's real
scripts/tests/test-setup.tsassetupFiles, two-test oracle): with the hook —Tests 2 passed (2); with the parent-commit setup file (no yield) —FAIL event-loop-yield.test.js > observes the event loop turned between tests / AssertionError: expected false to be true. Deterministic flip.Suggested fix: add a small
scripts/tests/event-loop-yield.test.js— test 1 arms a flag from a real macrotask callback (setTimeout(..., 0)— notprocess.nextTick, which is a microtask), test 2 asserts the flag fired. The probe verified this pair fails on the parent commit and passes with the hook.中文说明
目前没有任何自动化测试来固定本钩子所确立的让出(yield)不变量。评审者测试计划中的变异检查是手动执行的("删除
beforeEach让出……失败必须复现"),因此本 PR 合并后,CI 中没有任何东西能阻止未来的修改悄悄移除该让出:清理性重构、重构为globalSetup、或改变 setup 文件钩子语义的 vitest 升级,都可能在没有任何测试失败的情况下移除或使该钩子失效。回归会在下一次发布时首次暴露:一个长时间同步运行的脚本套件(仅 autofix-workflow 套件就会停滞约 66 秒)将再次触发 vitest 固定的 60 秒onTaskUpdateRPC 超时——也就是本 PR 修复的 v0.22.1 发布失败(Linux 发布通道上所有测试全绿却退出码 1;非 Linux 通道则被dangerouslyIgnoreUnhandledErrors静默吞掉)。已通过探针验证(在隔离的临时树中使用 vitest 3.2.7,以本仓库真实的
scripts/tests/test-setup.ts作为setupFiles,采用双测试预言机):带钩子 ——Tests 2 passed (2);换成父提交的 setup 文件(无让出)——FAIL event-loop-yield.test.js > observes the event loop turned between tests / AssertionError: expected false to be true。确定性翻转。建议修复:新增一个小的
scripts/tests/event-loop-yield.test.js—— 测试 1 从一个真实宏任务回调(setTimeout(..., 0)——而不是微任务process.nextTick)中置位一个标志,测试 2 断言该标志已置位。探针已验证该测试对在父提交上失败、带钩子时通过。— qwen3.8-max via Qwen Code /review (v0.22.0)