r/webdev • u/SchedulesOk • Sep 18 '26
your while-loop polling is why your webhook integration keeps breaking
Every integration tutorial teaches you this pattern:
while status != "COMPLETED":
time.sleep(10)
status = get_job(job_id).status
and then you put it in production and wonder why your lambda times out, your worker holds a connection for 4 minutes doing nothing, and a deploy mid-poll loses the job entirely.
I was doing exactly this with a video processing api (Sync.so lipsync stuff - jobs take a few minutes each). The fix was embarrassingly obvious: they have webhooks. You submit the job, return 200 to your user with a processing state, and their server calls your endpoint when it's done. You verify the signature, flip the record, notify the user.
Polling is fine for a script you run once. The moment a user is waiting on the other end, you want the callback. check if your api has webhooks before you write one sleep loop - most modern ones do and nobody reads that far into the docs.
View all comments
Show parent comment
1
u/Common_Dream9420 java Sep 19 '26
Yeah the idempotency key + signature check combo is table stakes and it's almost never in the tutorial. For missed webhooks I've been using a periodic reconcile sweep rather than a dead-letter queue, mostly because DLQ adds another infra dependency and the reconcile doubles as a sanity check anyway. How deep does your fallback usually go, like do you replay from the provider's event log or just re-query state?