Skip to content

vercel-flags-core: jitter ingest retries and batch-wait window#371

Merged
vincent-derks merged 1 commit intomainfrom
feat/jitter-ingest-retries
May 6, 2026
Merged

vercel-flags-core: jitter ingest retries and batch-wait window#371
vincent-derks merged 1 commit intomainfrom
feat/jitter-ingest-retries

Conversation

@vincent-derks
Copy link
Copy Markdown
Contributor

@vincent-derks vincent-derks commented Apr 30, 2026

Summary

The usage tracker's /v1/ingest retry path used a deterministic 100/200ms schedule with no jitter, and the 5s batch-wait window was likewise unjittered. Concurrent processes that started at the same moment would all flush together and, on a non-2xx, retry in lockstep — amplifying transient pressure.

Changes

  • Full-jitter exponential backoff between retry attempts (AWS-style: delay = random(0, base * 2^(attempt-1)), capped at 5s). Replaces the previous attempt * 100 ms schedule.
  • Jittered batch-wait window: MAX_BATCH_WAIT_MS is perturbed by ±20% on every flush so independent processes don't flush at the same wall-clock instant.
  • Log exhausted flushes: when all 3 retry attempts fail, emit a structured warning so consumers can alert on dropped batches. Previously these were silent.

Test plan

  • New unit tests in utils/backoff.test.ts covering exponential ceiling, custom baseMs/capMs, and the symmetric jitter bounds.
  • New integration tests in utils/usage-tracker.test.ts for the exhaustion log and no-exhaustion-on-success.
  • pnpm --filter @vercel/flags-core test → all pass.
  • pnpm --filter @vercel/flags-core check → clean.

@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Apr 30, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
flags-playground Ready Ready Preview, Comment, Open in v0 May 6, 2026 0:57am
flags-sdk-dev Ready Ready Preview, Comment, Open in v0 May 6, 2026 0:57am
flags-sdk-next-15 Ready Ready Preview, Comment, Open in v0 May 6, 2026 0:57am
flags-sdk-next-16 Ready Ready Preview, Comment, Open in v0 May 6, 2026 0:57am
flags-sdk-snippets Ready Ready Preview, Comment, Open in v0 May 6, 2026 0:57am
flags-sdk-sveltekit-snippets Ready Ready Preview, Comment, Open in v0 May 6, 2026 0:57am
shirt-shop Ready Ready Preview, Comment, Open in v0 May 6, 2026 0:57am
shirt-shop-api Ready Ready Preview, Comment, Open in v0 May 6, 2026 0:57am

Replace the deterministic 100/200ms retry schedule with full-jitter exponential
backoff, jitter MAX_BATCH_WAIT_MS by ±20% to desynchronize concurrent flushes,
and log when a flush exhausts all retries.

Helpers extracted to utils/backoff.ts so they can be reused.

Co-authored-by: Cursor <cursoragent@cursor.com>
@vincent-derks vincent-derks merged commit bd4d01a into main May 6, 2026
19 checks passed
@vincent-derks vincent-derks deleted the feat/jitter-ingest-retries branch May 6, 2026 13:57
@github-actions github-actions Bot mentioned this pull request May 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants