Repository navigation
Conversation
Payment trigger POST requests that fail for a reason that may be temporary (network error, timeout, 408, 425, 429 or 5xx) are now retried through a BullMQ queue, on the schedule proposed in #766: 5s, 10s, 30s, 1m, 5m, 10m, 30m and 1h after the first attempt, so up to 9 attempts. Each retry posts exactly what the first attempt posted, and is dropped if the trigger was deleted or its URL or data changed in the meantime. Other 4xx responses and post data that can't be built are not retried. Each attempt is logged with its number in the new TriggerLog.attempt column (1 for the first one), shown in the trigger logs table. Retries don't use credits: only the first attempt is charged, as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019G564i2sNiHJYQR95m8zGq
Contributor
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 52 minutes. View limit details
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. |
This branch has not been deployed
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.
Related to #766
Related to #1040
Description
When the server receiving a payment trigger's POST request is briefly down, times out, or answers with an error like 502, we now try again instead of giving up after one try.
Retries follow the schedule proposed in #766: 5 seconds, 10 seconds, 30 seconds, 1 minute, 5 minutes, 10 minutes, 30 minutes and 1 hour after the first try, so at most 9 tries in total. Each retry sends exactly the same data as the first try. We stop at the first success. We also stop if the trigger is deleted or edited in the meantime.
Requests that fail in a way a retry can't fix are not retried: most 4xx responses (bad request, not found, etc.) and post data that isn't valid JSON. Retries don't use credits; only the first try is charged, as before.
Every try is logged, and the trigger logs table has a new "Attempt" column (1 = first try, 2 = first retry, ...).
Test plan
make github-test-unit: all 19 suites / 412 tests pass. NewtriggerServicetests cover:npx tsc --noEmit -p .: no new kinds of errors in the changed files. The repo has pre-existing errors elsewhere, and the new BullMQconnection: redisBullMQline has the same pre-existing typing error as every other queue and worker.eslinton the changed files: clean.Remarks
triggerPostRetriesBullMQ queue (jobs/triggerPostRetryQueue.ts) with delayed jobs, one job per retry. The worker is registered injobs/initJobs.ts. Unlike the other queues, this one is not obliterated on startup, so pending retries survive restarts. The queue connection is opened lazily, on the first retry.TriggerLog.attempt INT NOT NULL DEFAULT 1(migration20261203130000_trigger_log_attempt). Existing logs read as attempt 1.constants/index.ts(TRIGGER_POST_RETRY_SCHEDULE_MS,TRIGGER_POST_MAX_ATTEMPTS,TRIGGER_POST_RETRY_CONCURRENCY). Instead of "hourly from here" without end, retries stop after the 1-hour one to keep them bounded.isRetryablePostError.services/triggerService.tsand its tests, so the others may need a small rebase after one is merged.Generated by Claude Code