TEST-04: Wall-clock sleeps for async synchronization (~90 frontend setTimeout waits, several Go sleeps) #36
Description
Severity: P3. Confidence: high. Informational.
Affected files:
frontend/src/__tests__/auth.test.ts:126frontend/src/__tests__/auth.test.ts:162internal/scheduler/scheduler_test.go:1278internal/api/ri_utilization_cache_test.go:256-262internal/server/integration_test.go:87
Evidence:
43 occurrences of 50ms await new Promise(resolve => setTimeout(resolve, 50)) plus 25 of 10ms and 3 of 100ms across frontend suites, used as fixed waits for async handlers (fake timers are used elsewhere, so the alternative is known). Go: a 20ms sleep to assert a goroutine did NOT fire, 250ms/200ms sleeps against real TTLs, a 100ms "Simulate actual work" sleep.
Impact:
3-5s of dead wall time per frontend run plus CI-load-sensitive flake windows; the 20ms negative-assertion window can miss a slow wrongly-spawned goroutine (false green on the Lambda invariant it guards). The anti-pattern is forbidden by the project's feedback_no_sleep_in_tests rule.
Recommendation:
Frontend: microtask flushes, fake timers, or awaiting the mocked API promise. Go: inject a hook/channel for the negative assertion; fake clock for TTL tests.
Source: docs/reviews/codebase-review-2026-06-10.md (automated multi-dimension code review, adversarially verified for P1/P2)
Activity
IAmJSD commentedon Oct 23, 2026
Claiming: working on this
Merge remote-tracking branch 'origin/main' into fix/issue-36
test: wait on goroutines and barriers instead of wall-clock sleeps in…
test(frontend): wait for async handlers instead of sleeping in unit t…
test: drive the in-memory rate limiter and the shutdown wait test wit…
IAmJSD commentedon Oct 28, 2026
Status update (2026-10-28): #1568 (Go: injectable clock for the in-memory rate limiter, deterministic shutdown-wait test) and #1569 (frontend: 123 fixed sleeps replaced with promise flushes, plus a guard test) merged.
Left: a few remaining sleeps that stand in for synchronization, for example
internal/archera/provider_cancel_test.go:111.test(config): observe lock contention instead of a quiet window in th…
test(api): observe lock waits instead of fixed windows in the ladder …
test(purchase): open the provider-lock race barriers on observed lock…
test: prove absences with synctest and Close ordering instead of quie…