perf: paginate wakatime/sync users query (#3161) - #3203
Merged
Priyanshu-byte-coder merged 1 commit intoJul 19, 2026
Merged
Conversation
/api/wakatime/sync did one unbounded `.select()` and pulled every user
with a wakatime API key (plus their encrypted keys) into serverless
memory in a single response. At a few thousand users that would either
hit Supabase's ~4.5 MB response cap, blow the function timeout, or get
killed by the memory limit — and the nightly sync would silently fail.
Adopt the same pagination pattern already in use by /api/cron/sync:
PAGE_SIZE=50, deterministic .order("id"), .range(page*50, page*50+49),
break out when a short page is returned. Kept the inner Promise.allSettled
CHUNK_SIZE=5 for API-call parallelism inside each page.
Fixes Priyanshu-byte-coder#3161
GSSoC Label Checklist 🏷️@Priyanshu-byte-coder — please apply the appropriate labels before merging: Difficulty (pick one):
Quality (optional):
Validation (required to score):
|
Contributor
Author
|
starred the repo — should turn the star-required gate green on the next re-run 🌟 |
Priyanshu-byte-coder
merged commit Jul 19, 2026
f13be04
into
Priyanshu-byte-coder:main
6 of 7 checks passed
|
🎉 Merged! Thanks for contributing to DevTrack. If the project has been useful to you, a ⭐ star on the repo is the easiest way to support it — it helps DevTrack get discovered by more developers. Keep an eye on open issues for your next contribution! |
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.
Summary
`/api/wakatime/sync` did one unbounded `.select()` and pulled every user with a wakatime API key (plus their encrypted keys) into serverless memory in a single response. At a few thousand users that would either:
and the nightly sync would silently fail.
What changed
Adopted the same pagination pattern already in use by `/api/cron/sync`:
Kept the inner `Promise.allSettled` `CHUNK_SIZE = 5` for parallelism across the Wakatime API within each page — that part was already sensible, just needed to be nested inside the pagination.
What's unchanged
Decrypt-then-fetch-then-upsert logic per user is identical. No behavior change for the actual sync — only the fetch/scan strategy differs.
Test plan
Fixes #3161