Skip to content

fix: paginate weekly-digest cron query to prevent serverless timeout#2363

Open
Meera2906 wants to merge 2 commits into
Umbrella-io:mainfrom
Meera2906:fix/weekly-digest-cron-timeout
Open

fix: paginate weekly-digest cron query to prevent serverless timeout#2363
Meera2906 wants to merge 2 commits into
Umbrella-io:mainfrom
Meera2906:fix/weekly-digest-cron-timeout

Conversation

@Meera2906

Copy link
Copy Markdown
Contributor

Problem

The weekly-digest cron fetched all opted-in users in a single unbounded
Supabase query. With 200+ users and ~300ms per email send, the function
reliably exceeded Vercel's 60s timeout, causing partial delivery with no
retry mechanism.

Fix

Replaced the unbounded query with a paginated loop using .range():

  • PAGE_SIZE = 50 rows fetched per Supabase query
  • Existing BATCH_SIZE = 5 parallel email sends is preserved per page
  • Each iteration stays well within the serverless timeout window
  • totalFetched added to logs for observability

Fixes #1852

@github-actions github-actions Bot added gssoc26 GSSoC 2026 contribution type:bug GSSoC type bonus: bug fix labels Jun 12, 2026
@github-actions

Copy link
Copy Markdown

GSSoC Label Checklist 🏷️

@Priyanshu-byte-coder — please apply the appropriate labels before merging:

Difficulty (pick one):

  • level:beginner — 20 pts
  • level:intermediate — 35 pts
  • level:advanced — 55 pts
  • level:critical — 80 pts

Quality (optional):

  • quality:clean — ×1.2 multiplier
  • quality:exceptional — ×1.5 multiplier

Validation (required to score):

  • gssoc:approved — counts for points
  • gssoc:invalid / gssoc:spam / gssoc:ai-slop — does not score

Type labels (type:*) are auto-detected from files and title. Review and adjust if needed.
Points formula: (difficulty × quality_multiplier) + type_bonus

@github-actions github-actions Bot added type:feature GSSoC type bonus: new feature type:performance GSSoC type bonus: performance (+15 pts) labels Jun 12, 2026
@Priyanshu-byte-coder Priyanshu-byte-coder added the gssoc:approved GSSoC: PR approved for scoring label Jun 16, 2026
@Priyanshu-byte-coder

Copy link
Copy Markdown
Member

This PR has merge conflicts with the current main branch. Please rebase or merge main into your branch to resolve the conflicts, then push the updated branch. Once conflicts are resolved, this PR will be merged.

git fetch origin main
git merge origin/main
# resolve conflicts
git push

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

Labels

gssoc:approved GSSoC: PR approved for scoring gssoc26 GSSoC 2026 contribution type:bug GSSoC type bonus: bug fix type:feature GSSoC type bonus: new feature type:performance GSSoC type bonus: performance (+15 pts)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: weekly-digest cron fetches all opted-in users with no limit, causing serverless timeout when user count is large

2 participants