From bf63766d885c17fd5c9696670e78278a3904ee94 Mon Sep 17 00:00:00 2001 From: Suzumiya Date: Thu, 10 Sep 2026 20:00:58 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=99=20SpacetimeDB=20=E5=86=92=E7=83=9F?= =?UTF-8?q?=E7=94=A8=E4=BE=8B=E7=9A=84=E6=9D=80=E8=BF=9B=E7=A8=8B=E6=96=AD?= =?UTF-8?q?=E8=A8=80=E5=8A=A0=E5=B1=80=E9=83=A8=E6=9C=89=E7=95=8C=E8=B6=85?= =?UTF-8?q?=E6=97=B6=EF=BC=9A=E5=8F=AA=E6=94=B9=E8=BF=99=E4=B8=80=E6=9D=A1?= =?UTF-8?q?=EF=BC=8C=E4=B8=8D=E5=8A=A8=E5=85=A8=E5=B1=80=E9=A2=84=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - spacetime-editor-idempotency-smoke.test.ts:terminates a live standalone-shaped child process 补第三参 20_000,并加注释写明这是负载敏感的局部超时。 - 性质说明:这是局部有界超时,不是放宽判据。断言 child.exitCode !== null || child.signalCode !== null 一字未动,全局 testTimeout 与 maxThreads 也未动。 - 为什么不加注入桩:该用例的存在意义就是验真实杀进程路径(spawn 真实常驻 node → stopStandalone → Windows 上 spawn taskkill /PID /T /F 杀进程树并等退出)。加桩等于把被测对象换掉,比放宽断言更隐蔽,因此明确不采用注入桩。 - 为什么需要:这两个真实进程的启动与回收在全并行负载下会明显超过默认 5000ms;单独跑实测 167ms,全仓并行时曾撞满 5000ms 上限。 - 上限仍具约束力:stopStandalone 自身对 SIGTERM → SIGKILL 只有 5s 有界等待,而 runTaskKill 与 SIGKILL 之后的 once(child, 'exit') 都没有内部超时,20s 外层上限仍能抓住真实挂死。 - 已实测第三参在当前 vitest 0.34.6 生效:临时把该值改成 1 时复现 Test timed out in 1ms,改回 20_000 后该文件 4 passed。 --- scripts/spacetime-editor-idempotency-smoke.test.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/spacetime-editor-idempotency-smoke.test.ts b/scripts/spacetime-editor-idempotency-smoke.test.ts index cc6819746..f485733d7 100644 --- a/scripts/spacetime-editor-idempotency-smoke.test.ts +++ b/scripts/spacetime-editor-idempotency-smoke.test.ts @@ -69,6 +69,11 @@ describe('SpacetimeDB editor idempotency smoke parsers', () => { }); describe('SpacetimeDB editor idempotency smoke cleanup', () => { + // 本用例真会拉起真实子进程:spawn 一个常驻 node,再由 stopStandalone 在 Windows 上 + // spawn taskkill /PID /T /F 杀进程树并等退出。全并行负载下这两个真实进程的启动与回收 + // 会明显超过 vitest 默认的 5000ms,因此只给这一条设局部有界超时,不动全局 testTimeout + // 与 maxThreads。这里不加注入桩:本用例的意义就是验真实杀进程路径,加桩等于换掉被测对象。 + // stopStandalone 自身对 SIGTERM → SIGKILL 只有 5s 有界等待,20s 外层上限仍能抓住真实挂死。 it('terminates a live standalone-shaped child process', async () => { const child = spawn( process.execPath, @@ -79,5 +84,5 @@ describe('SpacetimeDB editor idempotency smoke cleanup', () => { await stopStandalone(child); expect(child.exitCode !== null || child.signalCode !== null).toBe(true); - }); + }, 20_000); });