mirror of
https://github.com/garrytan/gbrain.git
synced 2026-07-30 19:49:14 +00:00
bun ignores bunfig.toml's timeout key, and beforeAll/beforeEach hooks do NOT inherit a test's third-arg timeout — a bare `bun test` gives every hook the 5000ms default even when all tests in the file declare 30s+. Measured on bun 1.3.14: a 6s hook dies at ~5001ms with the signature `(unnamed) [5001ms] ... hook timed out` (the #3545 jsonb-parity CI failure); both `beforeAll(fn, ms)` and the CLI `--timeout` flag are enforced hook budgets (kills observed at exactly the configured ms). Fixes: - e2e.yml (jsonb-parity, tier1, tier2) and release.yml ran bare `bun test`; they now pass --timeout=60000 like every scripts/ runner. - test/e2e/jsonb-roundtrip.test.ts (the #2339 double-encode guard, which only real Postgres can surface) additionally carries per-hook 60s budgets so a bare local run can't flake either — same pattern as its sibling op-checkpoint-jsonb-parity.test.ts. - scripts/check-bun-test-timeout.sh: CI guard (run from test.yml's verify job) failing any future bare `bun test` in workflows/scripts. - scripts/run-e2e.sh: correct the comment claiming --timeout is per-test-only (it covers hooks; the outer gtimeout exists for sync-blocking WASM hangs where no timer can fire). Proof: with Postgres paused for 6s during setupDB's connect, the unfixed file fails at 5001.81ms with the exact CI signature; the fixed file passes the identical condition (5 pass, 6.57s). 396 slow before-hooks across 362 test files lack per-hook budgets; all of them run through --timeout-passing invocations after this change, enforced by the new guard. Co-authored-by: Garry Tan <garrytan@gmail.com> Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
42 lines
1.8 KiB
Bash
Executable File
42 lines
1.8 KiB
Bash
Executable File
#!/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."
|