Skip to content

[client] Implement countdown timer accuracy fix for sub-second drift #828

Description

@Otaiki1

Summary

client/src/hooks/useCountdown.ts drives the CountdownTimer component. setInterval-based countdowns accumulate drift over time (~1 second per hour). For raffles ending in hours, this can show incorrect end times.

What to do

  1. Replace the setInterval approach with a requestAnimationFrame loop that re-syncs to Date.now() on every frame.
  2. Alternatively, use performance.now() as a stable reference and re-compute remaining time on each tick.
  3. Write a unit test using vi.useFakeTimers() that advances time by 1 hour and asserts the displayed remaining time is accurate to within 1 second.

Acceptance criteria

  • After advancing fake timers by 1 hour, the countdown display is within 1 second of the correct value.
  • The component re-calculates from the endTime on every tick rather than decrementing a counter.

Metadata

Metadata

Assignees

Labels

Stellar WaveFull ecosystem refactor initiative

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions