Skip to content

TEST-04: Wall-clock sleeps for async synchronization (~90 frontend setTimeout waits, several Go sleeps) #36

Open

Description

@cristim

Severity: P3. Confidence: high. Informational.

Affected files:

  • frontend/src/__tests__/auth.test.ts:126
  • frontend/src/__tests__/auth.test.ts:162
  • internal/scheduler/scheduler_test.go:1278
  • internal/api/ri_utilization_cache_test.go:256-262
  • internal/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

  1. IAmJSD commented on Oct 23, 2026

    @IAmJSD
    Collaborator

    Claiming: working on this

  2. self-assigned this
    on Oct 23, 2026
  3. IAmJSD commented on Oct 28, 2026

    @IAmJSD
    Collaborator

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions