Closed AndrewRayCode closed 9 months ago
In a Stripe webhook in Next.js api route src/pages/api/webhooks/stripe.ts
src/pages/api/webhooks/stripe.ts
import { buffer } from 'micro'; const action = async (req: NextApiRequest, res: NextApiResponse) => { console.log('raw body', req.body); const body = await buffer(req); console.log('parsed body', body); }
This hangs forever with both micro 9.4.0 and 10.0.0. Using Nextjs 13.4.2.
Sample console output:
raw body { id: '...', object: 'event', api_version: '2020-08-27', created: 1707460102, data: { object: { ... } } type: 'product.updated' }
As you can see, req.body is populated, but the parsed body line is never logged. The webhook callback hangs from Stripe and eventually times out.
req.body
parsed body
Failed to POST: Post "http://localhost:3030/api/webhooks/stripe": context deadline exceeded
I must have been doing something else wrong, because this is working for me now. I don't have an idea of what I changed to resolve this issue. But I am no longer seeing the await hang forever.
In a Stripe webhook in Next.js api route
src/pages/api/webhooks/stripe.ts
This hangs forever with both micro 9.4.0 and 10.0.0. Using Nextjs 13.4.2.
Sample console output:
As you can see,
req.body
is populated, but theparsed body
line is never logged. The webhook callback hangs from Stripe and eventually times out.