Skip to content

Fix infinite loop in calendar recurrence expansion#39

Merged
karolswdev merged 1 commit intomainfrom
hotfix/calendar-infinite-loop
Mar 30, 2026
Merged

Fix infinite loop in calendar recurrence expansion#39
karolswdev merged 1 commit intomainfrom
hotfix/calendar-infinite-loop

Conversation

@karolswdev
Copy link
Copy Markdown
Owner

HOTFIX — Production 504s

The expandBiweekly() function has an infinite loop when day_of_week is null. The condition while (anchor.getDay() !== null) never terminates because getDay() returns 0-6, never null. This blocks the Node event loop and causes all endpoints to 504.

Triggered when an admin creates a weekly/biweekly calendar entry without selecting a day of the week.

Fix

Added null guards to expandWeekly, expandBiweekly, and expandMonthly — they return early if required recurrence fields are missing.

Test plan

  • Verified the infinite loop is eliminated
  • Deploy via CI and confirm backend health check passes
  • Verify /api/calendar responds correctly

🤖 Generated with Claude Code

expandBiweekly and expandWeekly could spin forever when day_of_week
was null/undefined (e.g., admin creates a weekly entry without picking
a day). The while loop condition `anchor.getDay() !== null` is always
true, blocking the Node event loop and causing 504s on all endpoints.

Added null guards to all expansion functions so they bail out early
when required recurrence fields are missing.
@karolswdev karolswdev merged commit 2d388fe into main Mar 30, 2026
9 of 12 checks passed
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.

1 participant