vercel / nextjs-subscription-payments

Clone, deploy, and fully customize a SaaS subscription application with Next.js.
https://subscription-payments.vercel.app/
MIT License
5.83k stars 1.19k forks source link

"Promise<Response \| undefined>" is not a valid POST return type #248

Closed denisprado closed 5 months ago

denisprado commented 9 months ago

I am getting the follow error when deploying to vercel:

Failed to compile. 16:09:50.139 | src/app/api/webhooks/route.ts 16:09:50.140 | Type error: Route "src/app/api/webhooks/route.ts" has an invalid export: 16:09:50.140 | "Promise<Response | undefined>" is not a valid POST return type: 16:09:50.140 | Expected "Response | Promise", got "Promise<Response | undefined>". 16:09:50.140 | Expected "Promise", got "Promise<Response | undefined>". 16:09:50.140 | Expected "Response", got "Response | undefined". 16:09:50.140 | Expected "Response", got "undefined". `

but I have not changed this file. Any one guess what is happening?

jonkurtis commented 9 months ago

Same. I have not made any changes and now getting this error in build output.

jonkurtis commented 9 months ago

In the webhook this line is the problem: if (!sig || !webhookSecret) return You actually need to throw an error here so that the error will be caught and a Response can be returned. Like this: if (!sig || !webhookSecret) throw new Error("Missing Stripe Signature or Webhook Secret!")

Shivansh-yadav13 commented 9 months ago

Thanks @jonkurtis it solved the issue 👍

chriscarrollsmith commented 8 months ago

Opened a PR to fix this issue.

leerob commented 5 months ago

https://github.com/vercel/nextjs-subscription-payments/pull/278