Skip to content

feat: retry failed payment trigger POST requests - #1178

Open
Klakurka wants to merge 1 commit into
masterfrom
ccr-b62297cf-awgd35-trigger-retry
Open

Klakurka wants to merge 1 commit into
masterfrom
ccr-b62297cf-awgd35-trigger-retry

Conversation

@Klakurka

@Klakurka Klakurka commented Dec 3, 2026

Copy link
Copy Markdown
Member

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. New triggerService tests cover:
    • which errors are retried (network error/timeout, 408, 429, 5xx) and which aren't (400, 404, non-HTTP errors);
    • a 5xx on the first try schedules attempt 2 about 5s later and charges only 1 credit;
    • 4xx responses and unbuildable post data schedule nothing;
    • failing to schedule a retry doesn't break the batch;
    • a successful retry is logged with its attempt number, schedules nothing and charges nothing;
    • a failed retry is logged and schedules the next one at the right time;
    • nothing is scheduled after the last attempt;
    • retries of deleted, edited or missing triggers are dropped without posting.
  • npx tsc --noEmit -p .: no new kinds of errors in the changed files. The repo has pre-existing errors elsewhere, and the new BullMQ connection: redisBullMQ line has the same pre-existing typing error as every other queue and worker.
  • eslint on the changed files: clean.
  • Not run against a real Redis/BullMQ or a real receiving server. To check by hand: set a trigger to a URL that returns 502, make a payment, and watch the trigger logs fill with attempts 1, 2, 3, ...

Remarks


Generated by Claude Code

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
@coderabbitai

coderabbitai Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You'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.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 668f4c59-c578-4350-8957-c49deca9b1ae
Commits

Reviewing files that changed from the base of the PR and between f9d06f2 and 8fcc062.

Files selected for processing: 10

  • components/Trigger/TriggerLogs.tsx
  • constants/index.ts
  • jobs/initJobs.ts
  • jobs/triggerPostRetryQueue.ts
  • jobs/workers.ts
  • prisma-local/migrations/20261203130000_trigger_log_attempt/migration.sql
  • prisma-local/schema.prisma
  • services/triggerService.ts
  • tests/unittests/triggerService.test.ts
  • tests/unittests/workers.test.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

This branch has not been deployed

No deployments
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.

2 participants