Skip to content

Commit b0fe927

Browse files
committed
Merge remote-tracking branch 'origin/main' into claude/project-thread-e0g649
2 parents 03176c9 + 4d3a077 commit b0fe927

1 file changed

Lines changed: 54 additions & 2 deletions

File tree

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,56 @@
11
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
22

3-
// This package needs nothing beyond the shared preset; see its header.
4-
export { default } from '../../../vitest.preset.mts';
3+
import { accessSync, constants } from 'node:fs';
4+
import { defineConfig } from 'vitest/config';
5+
6+
// This package re-exported the shared preset until #27076. It now carries one
7+
// key of its own, `test.env.TMPDIR`, so the preset's one setting is restated
8+
// below (a merged or wrapped preset is not what
9+
// scripts/check-console-intercept-disarm.mjs judges in a config's place).
10+
// Every other key stays on vitest's defaults (`globals: false`,
11+
// `environment: 'node'`), exactly as under the bare re-export.
12+
//
13+
// ## Why TMPDIR points at a memory-backed directory
14+
//
15+
// The persistence tests write a real database file under `os.tmpdir()`, and
16+
// every flush ends in `atomicWriteFile`'s `handle.sync()` (fsync before the
17+
// rename; see wasm-connection.ts). An fsync waits for the disk's queue, and on
18+
// a Test Core shard that queue belongs to the other suites sharing the runner.
19+
// Measured (#27076): `should persist data on-write` takes about 30 ms on an
20+
// idle disk and 5,026 ms on schedule run 40654333991 (Test Core 6/8), where it
21+
// timed out; run 39853791549 timed out five on-write and flush cases the same
22+
// way. Locally, with four `dd … conv=fsync` writers on the same disk, those
23+
// cases took 1.4–3.6 s; with TMPDIR on /dev/shm under the same writers, every
24+
// case in the four persistence files stayed under 0.6 s.
25+
//
26+
// So the cases' wall time measured the neighbours' disk, not the driver. On a
27+
// tmpfs the same code still runs, `sync()` included: what each case asserts
28+
// (bytes on disk, atomic rename, the flush chain, the failure report) is
29+
// unchanged; only the wait for unrelated I/O is gone. Budgets, fixtures and
30+
// cases are untouched.
31+
//
32+
// A host without a writable /dev/shm (macOS, Windows) keeps its own temp
33+
// directory: the setting is absent there, not an error.
34+
const MEMORY_BACKED_TMP = '/dev/shm';
35+
36+
function writableDir(dir: string): boolean {
37+
try {
38+
accessSync(dir, constants.W_OK);
39+
return true;
40+
} catch {
41+
return false;
42+
}
43+
}
44+
45+
export default defineConfig({
46+
test: {
47+
// A late console.* must not redden a green suite (#10374): vitest's worker
48+
// forwards console output over RPC and discards the promise, and a write
49+
// landing after teardown's rpcDone() snapshot is rejected into an unhandled
50+
// error — a fully green run that exits 1. Disarming removes the mechanism.
51+
// Mechanism + measured costs: examples/app-showcase/vitest.config.ts.
52+
// Enforced repo-wide by scripts/check-console-intercept-disarm.mjs.
53+
disableConsoleIntercept: true,
54+
env: writableDir(MEMORY_BACKED_TMP) ? { TMPDIR: MEMORY_BACKED_TMP } : {},
55+
},
56+
});

0 commit comments

Comments
 (0)