Skip to content

test(webhooks): cover webhook retry dead-letter persistence and replay (#2077) - #2205

Open
huangji6693-max wants to merge 1 commit into
LabsCrypt:mainfrom
huangji6693-max:test/issue-2077-webhook-retry-dead-letter
Open

huangji6693-max wants to merge 1 commit into
LabsCrypt:mainfrom
huangji6693-max:test/issue-2077-webhook-retry-dead-letter

Conversation

@huangji6693-max

Copy link
Copy Markdown

Summary

Adds deterministic unit test coverage in backend/src/services/__tests__/webhookRetryProcessor.test.ts for webhook retry dead-letter persistence, replay, and cron telemetry in backend/src/services/webhookRetryProcessor.ts and backend/src/services/webhookService.ts:

  • Max retry attempts & network error dead-lettering: Verifies that when a retry reaches MAX_RETRY_ATTEMPTS (attempt_count = 4) on either HTTP failure or network exception (ECONNRESET), next_retry_at is set to NULL so the delivery is dead-lettered and excluded from future polling.
  • Dead-letter inspection: Verifies getSubscriptionDeliveries exposes dead-lettered delivery records with attemptCount = 4, lastStatusCode, lastError, and deliveredAt = undefined.
  • Dead-letter replay: Verifies that when an operator re-queues a dead-lettered delivery (attempt_count < MAX_RETRY_ATTEMPTS, next_retry_at <= now), WebhookService.processRetries() delivers the payload, sets delivered_at, and clears next_retry_at = NULL.
  • Retry processor lock recovery: Verifies that if refreshWebhookRetryQueueDepth throws during a scheduled tick, jobMetricsService.recordFailure is recorded and the inFlight lock is released in finally so subsequent ticks continue processing.

Closes #2077

Verification

  • node --experimental-vm-modules node_modules/jest/bin/jest.js src/services/__tests__/webhookRetryProcessor.test.ts: 15 passed, 0 failed.

Payout Wallets

  • Stellar (XLM / USDC): GBYWLISGOUWQ43VQEGXX6KRGDZ3CKAFFK3JXVLXKDO5TIFJUJ3OHJYOZ
  • EVM / Base USDC: 0x380C97bcbcAEf29DAc2d0ba7E180F1b4A7F38fdd
  • Solana (USDC / SOL): AyXYaA9Nf4z5fpLKY6DmubWe6D2qveMd79w8pEDNHcDw

@github-actions github-actions Bot added the security:malware-suspected Automated malware indicator found in a pull request label Oct 27, 2026
@github-actions

Copy link
Copy Markdown

Malware detection scan flagged this pull request

The scan found 1 indicator(s) in the PR diff. This PR is blocked until a maintainer reviews the flagged files.

  • backend/src/services/__tests__/webhookRetryProcessor.test.ts — hidden-appended-config-payload (high)

This is an automated triage signal; maintainers must verify whether the finding is malicious or intentional.

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

security:malware-suspected Automated malware indicator found in a pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[test] Cover webhook retry dead-letter handling

1 participant