Skip to content

fix: switch event invitations to async delivery to prevent timeout on large chapters - #2759

Merged
olleolleolle merged 2 commits into
masterfrom
fix/event-invitation-timeout
Jul 30, 2026
Merged

fix: switch event invitations to async delivery to prevent timeout on large chapters#2759
olleolleolle merged 2 commits into
masterfrom
fix/event-invitation-timeout

Conversation

@mroderick

@mroderick mroderick commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator

Description

Fixes #2758

InvitationManager#send_event_emails sends one email at a time using deliver_now in a synchronous loop. For a chapter like London (~4,300 eligible members), this takes ~40 minutes — past both DelayedJob's 9-minute max run time and the Heroku Scheduler dyno timeout.

This PR switches to deliver_later (matching the existing workshop pattern), so each email becomes its own DJ job with an independent 9-minute timeout. The outer job finishes in seconds (just creating records + enqueuing).

Changes

  • app/services/invitation_manager.rb: deliver_now to deliver_later in both invite_students_to_event and invite_coaches_to_event; wrap outer method in Rollbar rescue for production visibility
  • spec/services/invitation_manager_spec.rb: add tests for email delivery count and Rollbar error reporting

Test coverage

1158 examples, 0 failures across the full suite.

@mroderick
mroderick force-pushed the fix/event-invitation-timeout branch from 32dc788 to ad426a3 Compare July 29, 2026 10:30
… large chapters

`InvitationManager#send_event_emails` sends one email at a time using
`deliver_now` in a synchronous loop. For a chapter like London (~4,300
eligible members), this takes ~40 minutes — past both DelayedJob's
9-minute max run time and the Heroku Scheduler dyno timeout.

Switch to `deliver_later` (matching the existing workshop pattern), so
each email becomes its own DJ job with an independent 9-minute timeout.
The outer job finishes in seconds (just creating records + enqueuing).

Also:
- Wrap the outer method in a Rollbar rescue so batch-level failures
  are visible in production without relying on silent DJ retries
- Add tests for email delivery count and Rollbar error reporting

Fixes #2758
@mroderick
mroderick force-pushed the fix/event-invitation-timeout branch from ad426a3 to c3d4dce Compare July 29, 2026 10:53
@mroderick
mroderick marked this pull request as ready for review July 29, 2026 10:56
@mroderick
mroderick requested a review from olleolleolle July 30, 2026 08:23
@olleolleolle
olleolleolle enabled auto-merge July 30, 2026 08:41
@olleolleolle
olleolleolle merged commit 6344c5e into master Jul 30, 2026
9 checks passed
@olleolleolle
olleolleolle deleted the fix/event-invitation-timeout branch July 30, 2026 09:45
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.

Event invitation sending times out on large chapters

2 participants