Skip to content

Commit 29ef049

Browse files
committed
fix(service-datasource): 补 vitest 超时配置覆盖空洞并复核 pool 用例并发隔离 (#6044)
两条腿: 1. 覆盖空洞:本包此前没有任何 vitest 配置文件,全部用例吃 vitest 默认 5000ms —— #4856 把 testTimeout 逐包落在各包自己的 vitest.config.ts, 结构上覆盖不到没有该文件的本包。补 vitest.config.ts,testTimeout: 60_000 沿用 #4856 的取值不引入新数字,落在配置层使后续新增用例到达即被覆盖。 实测:flaky 用例(datasource-pool-support :122)是全文件第一个走到 `await import('@objectstack/driver-sql')`(knex)的用例,空载 1088ms, 对 5000ms 只有约 4.6 倍余量,队列全量并发下被吃掉即超时 —— 与签名吻合 (仅队列全量构建间歇红,受害 PR 自身全绿)。探针复核:6s 睡眠用例改前 以 "Test timed out in 5000ms" 变红、改后 6.2s 变绿,证明包级配置即生效层。 2. 并发隔离复核(分诊座位明令不许只调超时收尾):逐项排查文件/句柄/共享 状态 —— sqlite 构建落 :memory: 且生产路径不探测、不开连接、native addon 惰性不加载,零文件 I/O;Door-1 各用例 disconnect 销毁空 knex pool; Door-2/3 全部用 per-case fake;无临时文件、无端口、无跨用例可变共享状态。 结论:该红是真实一次性导入成本上的负载方差,不是泄漏,无需修隔离。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015a5qkLzpGXhLL2F5gvJ7dD
1 parent be59695 commit 29ef049

2 files changed

Lines changed: 53 additions & 0 deletions

File tree

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
"@objectstack/service-datasource": patch
3+
---
4+
5+
fix(service-datasource): give this package's vitest run a 60s `testTimeout` — close the #4856 coverage hole that let the merge queue evict unrelated PRs (#6044)
6+
7+
`packages/services/service-datasource` had no `vitest.config.ts` at all, so
8+
every case ran under vitest's **5000ms** default. #4856 fixed this class of
9+
flake by setting per-package timeouts in each package's own `vitest.config.ts`
10+
— a structure that cannot reach a package with no config file to carry it.
11+
12+
The cases that build a REAL driver pay a one-time `@objectstack/driver-sql`
13+
(knex) import inside the first case that reaches it. In
14+
`datasource-pool-support.test.ts` the pool rejections throw before that import,
15+
so "sqlite WITHOUT a pool still builds exactly as before" is the first case
16+
through it: measured idle it runs ~1.1s while its neighbours run 0-2ms (the
17+
postgres/mysql cases ride the module cache at 31/82ms). ~4.6x headroom against
18+
5000ms holds on a PR branch and not on a merge-queue runner building several
19+
PRs' batches at once — the observed signature: intermittent reds only in queue
20+
full builds, evicting PRs that never touched this package (#5999 twice, #5973
21+
once, 2026-08-06).
22+
23+
`testTimeout: 60_000` reuses #4856's value rather than inventing a new number,
24+
set at the config layer so future cases are covered on arrival. Isolation was
25+
reviewed rather than assumed (the #6044 triage forbade a timeout-only closure):
26+
the flaky case builds `:memory:`, unprobed on the production path, never opens
27+
a connection or loads the native addon, and every factory-door case destroys
28+
its knex handle; the boot and wizard doors run on per-case fakes. No temp
29+
files, no ports, no shared mutable state across cases — the red was load
30+
variance on a real one-time import, not a leak.
31+
32+
No runtime, schema or public API change — test configuration only.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
2+
3+
import { defineConfig } from 'vitest/config';
4+
5+
export default defineConfig({
6+
test: {
7+
environment: 'node',
8+
// This package had no vitest config at all, so every case ran under
9+
// vitest's 5000ms default — the structural hole #4856 could not cover
10+
// (it set per-package timeouts in each package's own vitest.config.ts,
11+
// and this package had none). The cases that build a REAL driver pay a
12+
// one-time `@objectstack/driver-sql` (knex) import inside the first case
13+
// that reaches it: measured idle that case runs ~1.1s
14+
// (datasource-pool-support "sqlite WITHOUT a pool"), leaving ~4.6x
15+
// headroom that a loaded merge-queue runner eats — the #6044 signature
16+
// (green on every PR branch, intermittently red only in queue full
17+
// builds). 60s reuses #4856's value rather than inventing a new number,
18+
// set at the config layer so future cases are covered on arrival.
19+
testTimeout: 60_000,
20+
},
21+
});

0 commit comments

Comments
 (0)