Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
fix(test): give slow setup hooks a real timeout budget (#3566)
Time Attakc913d2d7f794a
diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.ymlindex b59ecddb86..9d467f5134 100644--- a/.github/workflows/e2e.yml+++ b/.github/workflows/e2e.yml@@ -61,7 +61,10 @@ jobs:- name: Run JSONB double-encode parity tests on real Postgresenv:DATABASE_URL: postgresql://postgres:postgres@localhost:5432/gbrain_test- run: bun test test/e2e/op-checkpoint-jsonb-parity.test.ts test/e2e/jsonb-roundtrip.test.ts+ # --timeout also raises bun's 5s default hook budget (beforeAll/afterAll+ # do NOT inherit a test's third-arg timeout; verified on bun 1.3.x).+ # Every runner script in scripts/ passes it; bare invocations must too.+ run: bun test --timeout=60000 test/e2e/op-checkpoint-jsonb-parity.test.ts test/e2e/jsonb-roundtrip.test.tstier1:name: Tier 1 (Mechanical)@@ -88,7 +91,7 @@ jobs:bun-version: 1.3.13- run: bun install- name: Run Tier 1 E2E tests- run: bun test test/e2e/mechanical.test.ts test/e2e/mcp.test.ts+ run: bun test --timeout=60000 test/e2e/mechanical.test.ts test/e2e/mcp.test.tsenv:DATABASE_URL: postgresql://postgres:postgres@localhost:5432/gbrain_test@@ -155,7 +158,7 @@ jobs:}EOF- name: Run Tier 2 skill tests- run: bun test test/e2e/skills.test.ts test/e2e/zeroentropy-live.test.ts+ run: bun test --timeout=60000 test/e2e/skills.test.ts test/e2e/zeroentropy-live.test.tsenv:DATABASE_URL: postgresql://postgres:postgres@localhost:5432/gbrain_testOPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}diff --git a/.github/workflows/release.yml b/.github/workflows/release.ymlindex 9353f05b7a..a76445ba7e 100644--- a/.github/workflows/release.yml+++ b/.github/workflows/release.yml@@ -29,7 +29,9 @@ jobs:with:bun-version: 1.3.13- run: bun install- - run: bun test+ # --timeout matches every scripts/ runner and covers hook budgets too+ # (bunfig.toml's timeout key is ignored by bun; hooks default to 5s).+ - run: bun test --timeout=60000- run: bun run verify- run: bun build --compile --target=${{ matrix.target }} --outfile bin/${{ matrix.artifact }} src/cli.ts- name: Attest build provenancediff --git a/.github/workflows/test.yml b/.github/workflows/test.ymlindex 3cd1647f8c..d1da977dac 100644--- a/.github/workflows/test.yml+++ b/.github/workflows/test.yml@@ -113,6 +113,11 @@ jobs:key: bun-cache-${{ runner.os }}-${{ hashFiles('bun.lock') }}- run: bun install- run: bun run verify+ # Guard: no bare `bun test` in workflows/scripts — bun ignores+ # bunfig.toml's timeout, and hooks (beforeAll/afterAll) get the 5s+ # default regardless of per-test third-arg timeouts. Runs directly+ # (not via verify's CHECKS array) to avoid a package.json edit.+ - run: bash scripts/check-bun-test-timeout.shserial-tests:# *.serial.test.ts at --max-concurrency=1. Lives in its own runner sodiff --git a/scripts/check-bun-test-timeout.sh b/scripts/check-bun-test-timeout.shnew file mode 100755index 0000000000..31b098e5f0--- /dev/null+++ b/scripts/check-bun-test-timeout.sh@@ -0,0 +1,41 @@+#!/usr/bin/env bash+# CI guard: every `bun test` invocation in workflows and runner scripts must+# pass an explicit --timeout.+#+# Why: bun ignores bunfig.toml's `timeout` key (verified on 1.3.14), so a bare+# `bun test` gets the 5000ms default for BOTH tests and beforeAll/beforeEach/+# afterAll/afterEach hooks. Hooks do NOT inherit a test's third-arg timeout —+# a file whose tests all declare `}, 30_000)` still has a 5s hook budget, and+# slow setup (Postgres connect + migrations, PGLite cold start) flakes on+# loaded CI runners with the signature `(unnamed) [5001ms] ... hook timed out`+# (the #3545 jsonb-parity failure). The CLI --timeout flag is the one measured+# mechanism that raises the hook budget uniformly; per-hook second-arg+# timeouts work too but don't scale to ~400 slow hooks.+#+# Usage: scripts/check-bun-test-timeout.sh+# Exit: 0 when clean, 1 when a bare `bun test` invocation is found.++set -euo pipefail++ROOT="$(git rev-parse --show-toplevel 2>/dev/null || pwd)"+cd "$ROOT"++# Match executable `bun test` invocations. Exclude comment lines (#, //, *)+# and lines that already carry --timeout anywhere.+# Scope: workflows + runner scripts (the surfaces CI executes). package.json+# script bodies route through scripts/ already; editing it is out of scope here.+violations="$(grep -rnE '\bbun test\b' .github/workflows scripts 2>/dev/null \+ | grep -v -- '--timeout' \+ | grep -vE ':[[:space:]]*(#|//|\*)' \+ | grep -v 'check-bun-test-timeout' \+ || true)"++if [ -n "$violations" ]; then+ echo "FAIL: bare 'bun test' without --timeout (5s default kills slow setup hooks):" >&2+ echo "$violations" >&2+ echo "" >&2+ echo "Add --timeout=60000 (see scripts/run-unit-shard.sh for the convention)." >&2+ exit 1+fi++echo "OK: every bun test invocation passes an explicit --timeout."diff --git a/scripts/run-e2e.sh b/scripts/run-e2e.shindex 4cb0750849..acb39f9020 100755--- a/scripts/run-e2e.sh+++ b/scripts/run-e2e.sh@@ -162,8 +162,9 @@ for f in "${files[@]}"; doif [ -n "${DATABASE_URL:-}" ]; thenpsql "$DATABASE_URL" -At -c "SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE pid != pg_backend_pid() AND datname = current_database()" >/dev/null 2>&1 || truefi- # Hard outer timeout (180s per file). bun's --timeout is per-test; if a- # PGLite WASM call hangs in beforeAll/afterAll, --timeout never fires and+ # Hard outer timeout (180s per file). bun's --timeout covers tests AND+ # hooks (measured on 1.3.14), but it's timer-based: a PGLite WASM call+ # that blocks the event loop synchronously never lets the timer fire and# the file wedges indefinitely. gtimeout/timeout SIGKILLs the file so the# suite advances. gtimeout (macOS via coreutils) preferred; timeout (Linux)# fallback; bare bun (no outer cap) if neither is installed.diff --git a/test/e2e/jsonb-roundtrip.test.ts b/test/e2e/jsonb-roundtrip.test.tsindex 9834d52e00..ec9acfded9 100644--- a/test/e2e/jsonb-roundtrip.test.ts+++ b/test/e2e/jsonb-roundtrip.test.ts@@ -26,8 +26,12 @@ if (skip) {}describeE2E('E2E: JSONB roundtrip — v0.12.1 reliability wave', () => {- beforeAll(async () => { await setupDB(); });- afterAll(async () => { await teardownDB(); });+ // 60s hook budget: setupDB runs connect + the full migration chain, which+ // exceeds bun's default 5s hook timeout on loaded CI runners. Hooks do NOT+ // inherit a test's third-arg timeout (verified on bun 1.3.14) — they need+ // their own second-arg budget. Same pattern as op-checkpoint-jsonb-parity.+ beforeAll(async () => { await setupDB(); }, 60_000);+ afterAll(async () => { await teardownDB(); }, 60_000);test('putPage writes frontmatter as object, not double-encoded string', async () => {const engine = getEngine();