Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

await buffer(req) hangs forever, doesn't finish #485

Closed
AndrewRayCode opened this issue Feb 9, 2024 · 1 comment
Closed

await buffer(req) hangs forever, doesn't finish #485

AndrewRayCode opened this issue Feb 9, 2024 · 1 comment

Comments

@AndrewRayCode
Copy link

In a Stripe webhook in Next.js api route 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.

Failed to POST: Post "http://localhost:3030/api/webhooks/stripe": context deadline exceeded

@AndrewRayCode
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant