Repository navigation
test(server): drop avoidable waits from the slowest server tests - #667
Merged
Merged
Conversation
Rinat S (rsolmano)
requested review from
Olga Lavrichenko (OLavrik),
Rustam Sadykov (SBOne-Kenobi) and
danyaberezun
as code owners
October 6, 2026 22:14
Rinat S (rsolmano)
force-pushed
the
test-speedup-server
branch
from
October 7, 2026 06:16
d5a90e0 to
42fac75
Compare
Rinat S (rsolmano)
enabled auto-merge
October 7, 2026 06:17
5 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
An uncached
bun run testtakes ~2 min locally, and almost all of it is@thinkrail/server(115 s): its 97 test files run one after another, and a handful of tests spend seconds waiting on real time or doing expensive setup. The single slowest test startedgit commit200 times in a bash loop.Approach
Remove the avoidable waits without weakening any assertion. Each changed test was mutation-checked: I broke the guarded behaviour and confirmed the test fails.
git fast-importstream. It keeps the realCOMMIT_LIST_MAXand real git, so it still provesresolveListedCommitandlistCommitsuse the same limit.setSystemTimefor the history revalidate throttle. For the Central status TTL, aDate.nowoffset instead, because Bun freezes the clock aftersetSystemTimeand that code has its ownDate.now()deadlines.PostHogSinkOptionsgets an optionalretryDelayMs(default unchanged), and the tests pass 10 ms through the existinginitializeAnalyticsWithSinkFactoryForTestsseam.Left alone on purpose: the watch tests (they wait on the watcher's real debounce constants),
boot's "waits beyond one second", and therunBoundedtimeout tests, because their waits are what they test.Not in this PR:
bun test --parallel. It runs the server suite in ~20 s, but on Bun 1.4.2 about 1 in 6 runs hung for good: a worker spins at 100% CPU with a zombie child. That's oven-sh/bun#34069, a lost child exit inspawnSyncunder--parallel. The fix (oven-sh/bun#44581) is merged but not released yet. Follow-up: once a Bun release includes it, bump Bun and switchpackages/servertobun test --parallel.Changes
todos/adoptedCommits— newest-200 capanalytics/analytics.test.ts(whole file)auth/jbcentral— signed-out / stopped-proxy quotahistory/historyIndex— 2 s throttleterminal/terminalManager— attached-client + displaced tests@thinkrail/serversuite (serial)Production change: only
packages/server/src/analytics/sink.ts(+2 lines, an optionalretryDelayMs→ posthogfetchRetryDelay). Everything else is test-only.Screenshots
Not applicable — no frontend changes.
Related issues
None.
Checklist
bun run lint,bun run typecheck,bun run testbun run e2e, orbun run e2e:fullwhen touching agent behavior) — not app-affecting: test changes plus an optional, default-off sink optionSPEC.md/ top-level specs updated to reflect any boundary, contract, or behavior change — no boundary, contract or behavior changeTesting
bun run test -- --force→ 21/21 tasks; server 1340 tests, 0 fail, 97.3 sbun run lint→ clean;bun run typecheck→ 21/21FROM_DISPLACEDbun test src/terminal/terminalManager.test.ts×3 → 27 pass each--parallelinvestigation on Bun 1.4.2: 5 clean runs at ~19.7 s, then a hang with a 100%-CPU worker holding a zombie child (stack sample in a nativespawnSyncwait), matching Bug: spawnSync never returns: child exit lost (child stays zombie), wait loop busy-spins at 100% CPU re-registering a finished pipe reader (macOS ARM64) oven-sh/bun#34069