remotion
remotion copied to clipboard
Webhook callbacks not awaited, causing premature termination in serverless environments
Bug Description
The appRouterWebhook and pagesRouterWebhook helpers don't await async callbacks before returning responses. This causes async operations (database updates, API calls) to be terminated prematurely in serverless environments.
Reproduction
// This fails silently - database never updates
export const POST = appRouterWebhook({
secret: 'mysecret',
onSuccess: async ({ renderId, outputUrl }) => {
// This database update never completes
await db.update(jobs)
.set({ status: 'completed', outputUrl })
.where(eq(jobs.renderId, renderId));
},
});
Expected Behavior
Async operations in callbacks should complete before the response is returned.
Actual Behavior
- Response returns immediately
- Serverless function terminates
- Async operations are killed mid-execution
- No errors logged (silent failure)
Environment
- Next.js App Router / Pages Router
- Vercel / AWS Lambda / Any serverless platform
- @remotion/lambda version: 4.0.352+
Root Cause
Lines 54-60 in app-router-webhook.ts and lines 46-52 in pages-router-webhook.ts call callbacks without await.
Fixed in #5709