Fix: resolve webhook retry processor conflict and share retry config (#8)#28
Fix: resolve webhook retry processor conflict and share retry config (#8)#28Sam-Rytech wants to merge 1 commit into
Conversation
- Removed webhookRetryScheduler.ts as its logic conflicts with webhookService.ts - Extracted backoff config and max attempts into a shared config WEBHOOK_RETRY_CONFIG - Updated WebhookService.processRetries query to properly alias columns to avoid ambiguous references and to utilize the new config - Updated index.ts to wire up the surviving webhookRetryProcessor - Added test verifying retry processor respects backoff delays and max attempts Closes #123
ogazboiz
left a comment
There was a problem hiding this comment.
the shared retry config part is done right, WEBHOOK_RETRY_CONFIG is exported once from webhookService.ts and consumed there, the duplicate processor file is gone and index.ts is rewired consistently. but the branch does not build or test yet, and there's a design regression to sort:
-
build and test break on a dangling import of a deleted module.
src/tests/distributedLock.test.ts:38-39still doesawait import("../services/webhookRetryScheduler.js")and testsretryFailedWebhooksat line 53, but this pr deleted that file.npm run buildfails with TS2307 (cannot find module ../services/webhookRetryScheduler.js) and the test errors at runtime. remove or rewrite that describe block (the import at ~38-39 and the matchingdescribe("webhookRetryScheduler", ...)), or point it at the new processor. -
this drops the multi-instance safety that #23 just added. you deleted the lock-protected
webhookRetryScheduler.ts(it took a redis lock viacacheService.setNotExists(...:running)) and kept the unprotectedwebhookRetryProcessor.ts, which runsprocessRetries()every 10s with no lock.processRetries()in webhookService.ts:290 does a plainSELECT ... LIMIT 100with noFOR UPDATE SKIP LOCKED, so two instances will grab the same rows and double-send the webhooks. either bring the redis lock back around the processor interval, or addFOR UPDATE SKIP LOCKEDand mark rows in-flight. -
prettier fails on
src/services/__tests__/webhookRetryProcessor.test.tsandsrc/services/webhookService.ts. runnpx prettier --writeon both. -
minor:
MAX_RETRY_ATTEMPTSis hardcoded to 4 in webhookService.ts, replacing the old derivedRETRY_DELAYS_MS.length + 1. correct today (3+1) but it will silently drift if the delays array changes. considerRETRY_DELAYS_MS.length + 1.
get build + test + prettier green and restore the lock semantics and this is close.
if you want to keep contributing, join us on Telegram: https://t.me/+DOylgFv1jyJlNzM0
Description
This PR resolves the conflicting retry implementations between
webhookRetrySchedulerandwebhookService.Changes Made
webhookRetryProcessor.tsas the single surviving implementation and wired it intoindex.ts.webhookRetryScheduler.tsto remove duplicate sources of truth.WEBHOOK_RETRY_CONFIGused bywebhookService.ts.wd.id,ws.callback_url, etc.), avoiding ambiguous references and mapping correctly to the current schema.webhookRetryProcessor.test.tsasserting that the processor respects the configured backoff delays and max attempts.Closes #8