mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-10-21 05:40:14 +00:00
* fix(ci): yield the event loop between script tests to avoid vitest RPC timeouts (#10037) The v0.22.1 release quality job exited 1 on `npm run test:scripts` with every test green. vitest's worker->main `onTaskUpdate` RPC has a fixed 60s timeout; the synchronous spawnSync-driven script suites keep a forked worker's event loop blocked for an entire file (~66s on the heaviest suite), so the queued RPC response is never processed before the timer fires, surfacing as an unhandled `[vitest-worker]: Timeout calling "onTaskUpdate"` error. Linux keeps unhandled errors fatal (the scripts vitest config only exempts non-Linux since #9728), so the release died. Add a global per-test event-loop yield to the scripts test setup. The timer is captured at setup load so `vi.useFakeTimers()` inside a test cannot intercept the yield. Any continuous stall is now bounded by a single test, so RPC responses drain long before the 60s deadline. Real test failures stay fatal on every platform; the Linux unhandled-error signal is untouched. * fix(ci): state the actual yield invariant in the script test setup comment (#10037) * test(ci): pin the script-test event-loop yield invariant (#10037) --------- Co-authored-by: qwen-code-dev-bot <qwen-code-dev-bot@users.noreply.github.com> Co-authored-by: Shaojin Wen <shaojin.wensj@alibaba-inc.com>
32 lines
1.1 KiB
TypeScript
32 lines
1.1 KiB
TypeScript
/**
|
|
* @license
|
|
* Copyright 2025 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
import { beforeEach, vi } from 'vitest';
|
|
|
|
vi.mock('fs', async () => {
|
|
const actual = await vi.importActual<typeof import('fs')>('fs');
|
|
const appendFileSync = vi.fn();
|
|
return {
|
|
...actual,
|
|
appendFileSync,
|
|
default: {
|
|
...actual,
|
|
appendFileSync,
|
|
},
|
|
};
|
|
});
|
|
|
|
// Captured before any test can install fake timers, so this yield always
|
|
// uses the real timer. Suites made of synchronous spawnSync tests can keep
|
|
// a worker's event loop blocked for the whole file (>60s), which makes
|
|
// vitest's fixed 60s worker->main `onTaskUpdate` RPC timeout fire and the
|
|
// run exit 1 with every test green. Yielding between tests bounds any
|
|
// continuous stall to a single test, so the RPC response drains well before
|
|
// the deadline. (A single test, beforeAll, or module-level block stalling
|
|
// for 60s would still trip it: testTimeout cannot interrupt synchronous
|
|
// bodies.)
|
|
const realSetTimeout = setTimeout;
|
|
beforeEach(() => new Promise((resolve) => realSetTimeout(resolve, 0)));
|