#1389 Paused subscriptions with a resumeAt are never automatically resumed - #1412
Open
Olamidepy wants to merge 3 commits into
Open
#1389 Paused subscriptions with a resumeAt are never automatically resumed#1412Olamidepy wants to merge 3 commits into
Olamidepy wants to merge 3 commits into
Conversation
|
@Olamidepy Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Contributor
Author
|
Pls merge....... . @RUKAYAT-CODER |
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.
Added validation to reject past or invalid resumeAt dates with BadRequestException('resumeAt must be a future date').
When a future resumeAt is provided, calculates delay = resumeDate.getTime() - Date.now() and enqueues a delayed JOB_NAMES.RESUME_SUBSCRIPTION job in Bull queue with retry (attempts: 3, exponential backoff) and auto-removal on complete.
When resumeAt is omitted, the subscription pauses indefinitely without scheduling a queue job.
Idempotent Job Processing in
SubscriptionJobProcessor
:
Implemented @process(JOB_NAMES.RESUME_SUBSCRIPTION) handleResumeSubscription.
Safely handles missing subscriptions and cancelled subscriptions as clean no-ops.
Guards against double-resumption by returning early if isPaused is false.
Transitions paused subscriptions back to ACTIVE via SubscriptionsService.resumeSubscription().
Module Registration in
PaymentsModule
:
Registered QUEUE_NAMES.SUBSCRIPTIONS with BullModule.registerQueue.
Registered SubscriptionsService, SubscriptionsController, and SubscriptionJobProcessor.
Automated Unit Tests:
closes #1389
subscriptions.service.spec.ts
(7 tests covering past date rejection, pause with/without resumeAt, queue scheduling, and resume handling).
subscription-job.processor.spec.ts
(7 tests covering auto-resume execution, idempotency, cancelled/missing subscription safety, and Bull retry propagation).
All 14 tests pass and pnpm build compiles cleanly with 0 errors.