Skip to content

test(webhooks): add integration test for webhook retry on 500 response (#578)#581

Merged
Chucks1093 merged 1 commit into
accesslayerorg:mainfrom
Hollujay:test/578-webhook-retry-500-integration
Jul 19, 2026
Merged

test(webhooks): add integration test for webhook retry on 500 response (#578)#581
Chucks1093 merged 1 commit into
accesslayerorg:mainfrom
Hollujay:test/578-webhook-retry-500-integration

Conversation

@Hollujay

@Hollujay Hollujay commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Closes #578

Summary

Adds an integration test to verify that the webhook delivery system correctly retries after receiving a 500 Internal Server Error from the callback URL, rather than immediately marking the webhook as failing.

Test Approach

  1. Mock server: A local HTTP server is started that returns 500 on the first request and 200 on all subsequent requests. Request timestamps are recorded.
  2. Webhook registration: A webhook is created via Prisma pointing to the mock server URL.
  3. Event dispatch: dispatchWebhookEvent is called with a buy trade event, triggering delivery to the mock server.
  4. Retry verification:
    • The first attempt receives a 500 → the service applies exponential backoff (Math.pow(2, 1) * 1000 = 2000ms)
    • The second attempt receives a 200 → the event is marked DELIVERED
  5. Assertions:
    • Callback was called exactly twice (first fail, then success)
    • Time between calls ≥ 2000ms (correct backoff delay)
    • Webhook event status is DELIVERED with retryCount: 2
    • Webhook is not marked as isFailing: true (only flagged after all retries are exhausted)

Acceptance Criteria Met

  • Callback called twice: once failing, once succeeding
  • Webhook not marked as failed after successful retry
  • Retry fires after the configured backoff delay

Files Changed

  • src/modules/webhooks/webhook.integration.test.ts — Added the new test block with mock HTTP server and assertions

…slayerorg#578)

When a webhook callback URL returns a 500 error, the server should retry
delivery with exponential backoff rather than treating it as a permanent
failure. This integration test verifies:

- A callback returning 500 triggers exactly one retry
- The retry fires after the configured backoff delay (2^1 * 1000ms)
- On the second attempt (200), the webhook event status is DELIVERED
- The webhook is not marked as isFailing after a successful retry
@Chucks1093
Chucks1093 merged commit 2b85ef6 into accesslayerorg:main Jul 19, 2026
1 check passed
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.

Add integration test for webhook delivery retrying after a 500 response from callback URL

2 participants