Skip to content

fix: send scheduled campaigns on BullMQ 5 - #445

Open
vladbisceanu wants to merge 1 commit into
usesend:mainfrom
vladbisceanu:fix/campaign-batch-job-id-upstream
Open

fix: send scheduled campaigns on BullMQ 5#445
vladbisceanu wants to merge 1 commit into
usesend:mainfrom
vladbisceanu:fix/campaign-batch-job-id-upstream

Conversation

@vladbisceanu

@vladbisceanu vladbisceanu commented Aug 23, 2026

Copy link
Copy Markdown

Scheduled campaigns never leave SCHEDULED on BullMQ 5. The batch queue uses a custom job ID containing a colon, which BullMQ rejects with "Custom Id cannot contain :".

This changes the separator to a hyphen and adds a regression test at the CampaignBatchService.queueBatch call site.

Verification:

  • Reproduced against a deployed self-hosted instance
  • Confirmed the new test fails before the fix
  • Focused campaign service tests: 6 passed
  • Full web unit suite: 121 passed
  • Web typecheck passed
  • Focused ESLint passed
  • Production verification after the same fix: a scheduled campaign completed 1/1

Migration notes: none. No schema, configuration, or dependency changes.


Summary by cubic

Scheduled campaigns on bullmq 5 were stuck in SCHEDULED because the batch queue used a custom job ID with a colon, which bullmq rejects. We now use a hyphenated job ID, so campaigns enqueue and execute.

  • CampaignBatchService.queueBatch sets jobId to "campaign-batch-" (was "campaign-batch:"); preserves deterministic idempotency.
  • Adds a regression test that asserts a BullMQ-compatible job ID and verifies Queue.add receives the expected arguments; adjusts test mocks to spy on queue and contact updates.
  • No schema, configuration, or dependency changes; no migration actions.

Written for commit dc0bdae. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

  • Bug Fixes
    • Improved campaign batch processing by ensuring queued jobs use compatible identifiers.
  • Tests
    • Expanded coverage for campaign batch queuing and contact subscription updates.
    • Updated test scenarios to verify queued job details and webhook-related behavior.

@vercel

vercel Bot commented Aug 23, 2026

Copy link
Copy Markdown

@vladbisceanu is attempting to deploy a commit to the kmkoushik's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 61d0a2b6-8414-4d83-99fc-d0e53930b5b1

📥 Commits

Reviewing files that changed from the base of the PR and between bd83535 and dc0bdae.

📒 Files selected for processing (2)
  • apps/web/src/server/service/campaign-service.ts
  • apps/web/src/server/service/campaign-service.unit.test.ts

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.


Walkthrough

Campaign batch jobs now use hyphen-separated IDs in CampaignBatchService.queueBatch. Campaign service tests add shared mocks for queue insertion and contact updates. New tests verify the scheduled campaign payload and the campaign-batch-campaign_1 job ID. Unsubscribe and resubscribe assertions now use the contact update mock.

Suggested reviewers: kmkoushik

Merge Risk: ⚪ Minimal · up to dc0bd

This changes the scheduled-campaign job identifier to a BullMQ-compatible format so scheduled campaigns can enqueue and run; no actionable merge-blocking risk remains after normal checks and review.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the BullMQ 5 compatibility fix that enables scheduled campaigns to send.
Docstring Coverage ✅ Passed Docstring check was indeterminate for this PR — some files could not be analyzed in time. Not blocking.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

apps/web/src/server/service/campaign-service.ts

ESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox.

apps/web/src/server/service/campaign-service.unit.test.ts

ESLint skipped: the matched ESLint configuration already failed (missing-dependency).


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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