From c02957a40b9d60dcfc51fe1770b54a56b07c17ac Mon Sep 17 00:00:00 2001 From: yetone Date: Sun, 25 Oct 2026 14:24:25 +0800 Subject: [PATCH] layerfs: the tests' cleanup hooks get a 120s bar, not bun's 5s (#362) Both test files remove every temp dir in one afterAll. On a loaded box that took 6-7.5s and went red against bun's default 5s hook timeout. The hooks now carry their own bar. Run: with a 7s Bun.sleepSync injected into layerfs.test.mjs's hook, the old bar fails ("a beforeEach/afterEach hook timed out", 28 pass 1 fail) and the new one passes (28 pass 0 fail). Test-only change, so no version bump. --- packages/layerfs/layerfs.test.mjs | 5 ++++- packages/layerfs/no-magpie.test.mjs | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/layerfs/layerfs.test.mjs b/packages/layerfs/layerfs.test.mjs index 18737dd..b908e39 100644 --- a/packages/layerfs/layerfs.test.mjs +++ b/packages/layerfs/layerfs.test.mjs @@ -23,11 +23,14 @@ function mkTmp(prefix, base = tmpdir()) { tmpDirs.push(d) return d } +// The cleanup's time grows with the machine's disk load, not with the +// suite: on a loaded box removing every dir took over bun's default 5s +// hook bar (#362), so the hook carries its own. afterAll(() => { for (const d of tmpDirs) rmSync(d, { recursive: true, force: true }) for (const k of Object.keys(process.env)) if (!(k in envSnapshot)) delete process.env[k] Object.assign(process.env, envSnapshot) -}) +}, 120_000) function fixture() { const src = mkTmp("layerfs-src-") diff --git a/packages/layerfs/no-magpie.test.mjs b/packages/layerfs/no-magpie.test.mjs index 223df91..a1391f8 100644 --- a/packages/layerfs/no-magpie.test.mjs +++ b/packages/layerfs/no-magpie.test.mjs @@ -11,11 +11,14 @@ import { createBackend } from "./layerfs.mjs" const envSnapshot = { ...process.env } const dirs = [] const mk = (p) => { const d = mkdtempSync(join(tmpdir(), p)); dirs.push(d); return d } +// The cleanup's time grows with the machine's disk load, not with the +// suite: on a loaded box removing every dir took over bun's default 5s +// hook bar (#362), so the hook carries its own. afterAll(() => { for (const d of dirs) rmSync(d, { recursive: true, force: true }) for (const k of Object.keys(process.env)) if (!(k in envSnapshot)) delete process.env[k] Object.assign(process.env, envSnapshot) -}) +}, 120_000) const named = (s) => /magpie/i.test(String(s)) const message = async (p) => { try { await p; return "" } catch (e) { return String(e?.message ?? e) } }