feat: add structured error logging for webhook retry exhaustion#594
Merged
Chucks1093 merged 3 commits intoJul 23, 2026
Merged
Conversation
4 tasks
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.
PR: Webhook Retry Exhaustion Error Logging
Summary
Updated the webhook delivery retry-exhaustion log path to emit a single, structured
error-level log entry with full operator context. The log is emitted exactly once when a webhook exhausts all retry attempts and is flagged as failing. Individual retry failures continue to use the existingwarn-level log.Motivation
When a webhook exhausts all delivery retries and is flagged as failing, operators need enough structured context to identify the webhook and manually investigate the callback URL. The previous log entry was missing
event_typeand usedattempt_numberinstead oftotal_attempts, and did not include aflagged_attimestamp. This made it harder to correlate with other system events and to determine when the webhook was suspended.Changes
Modified Files
src/modules/webhooks/webhook.service.tssrc/modules/webhooks/webhook.service.test.tsBehavior Changes
attempt_numbertotal_attemptsevent_typein logevent_typeincludedflagged_atin logflagged_atincluded (ISO 8601 timestamp)logger.errorcalled exactly onceStructured Error Log Fields (on exhaustion)
webhook_idstringcreator_idstringevent_typestring"BUY"or"SELL").total_attemptsnumberlast_error_codestringflagged_atstringCallback URL Privacy
The callback URL never appears in the exhaustion log. The existing retry
warnlog continues to usemaskWebhookUrl()to log only the origin (e.g.,https://hooks.example.com).Implementation Details
The change is confined to the
attemptDelivery()function inwebhook.service.ts. When retries are exhausted (attempt >= maxAttempts):isFailing = true).WebhookEventrecords are marked asFAILED.logger.error()call emits the structured log with the fields listed above.Individual retry failures continue to emit
logger.warn()with backoff details and a masked callback URL.Formatting
Testing
Updated
webhook.service.test.tsto assert:logger.erroris called exactly once.webhook_id,creator_id,event_type,total_attempts,last_error_code, andflagged_at.total_attemptsequalsWEBHOOK_RETRY_MAX_ATTEMPTS.flagged_atis a valid string (checked viaexpect.any(String)).Verification
Run the targeted test:
pnpm test -- src/modules/webhooks/webhook.service.test.tsCloses #587