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

Webpack5 enabled API Route return Internal Server Error when deployed to vercel, but works fine locally #23894

Closed
sozonome opened this issue Apr 11, 2021 · 9 comments
Milestone

Comments

@sozonome
Copy link

sozonome commented Apr 11, 2021

What version of Next.js are you using?

10.1.3

What version of Node.js are you using?

14.15.3

What browser are you using?

Chrome

What operating system are you using?

Windows 10

How are you deploying your application?

Vercel

Describe the Bug

I have a project which have an API route which returns collection of data from markdowns using gray-matter. Works fine locally and when deployed to vercel. But problem occurs when I enable the webpack5 configuration in next.config.js, now the api route works fine locally, but it returns ISE (Internal Server Error) when deployed to vercel.

Expected Behavior

The api route should works fine locally and when being deployed to vercel with webpack5 enabled.

To Reproduce

Sample Repository to reproduce: https://github.com/sozonome/nextjs-webpack5-api-route-vercel-deployment-error
https://github.com/sozonome/nextjs-webpack5-api-route-vercel-deployment-error/blob/main/next.config.js

Expected (local dev screenshot):
image

Deployed (in vercel):
https://nextjs-webpack5-api-route-vercel-deployment-error.vercel.app/api/posts
image

@sozonome sozonome added the bug Issue was opened via the bug report template. label Apr 11, 2021
@dohomi
Copy link

dohomi commented Apr 14, 2021

@sozonome are you using i18n? I realized all my API routes on Vercel are now prepended with the locales and not available any longer as they used before. This results on all my API functions to result in 404

This seems like a major change after 10.1.3
Screenshot 2021-04-14 at 10 15 14

@sozonome
Copy link
Author

sozonome commented Apr 14, 2021

Nope, I didn't use / configure i18n, you can check the repo I attached.

My case only happened when I enable webpack5 and the internal server error only occurs in production deployment using vercel.

@dohomi
Copy link

dohomi commented Apr 14, 2021

@sozonome maybe we both don't have the same issue, but maybe open the deployment on Vercel and see inside of function if your function call is present. I just realized that on Vercel all my calls are prefixed with [locale] which leads online to all API calls to fail.

@sozonome
Copy link
Author

sozonome commented Apr 14, 2021

Yes I already confirm by checking my vercel deployment, it doesn't have any i18n prefix 😁

IMG_20210414_095017.jpg

@dohomi
Copy link

dohomi commented Apr 14, 2021

@sozonome yes I agree has nothing to do with i18n. I stripped it all down, the error only occurs in my Vercel deployements with webpack5 enabled, if I disable it and re-deploy the API routes are working again.

@timneutkens timneutkens added kind: bug and removed bug Issue was opened via the bug report template. labels Apr 14, 2021
@timneutkens timneutkens added this to the Iteration 19 milestone Apr 14, 2021
@sozonome sozonome reopened this Apr 15, 2021
@ijjk ijjk closed this as completed Apr 15, 2021
@ijjk
Copy link
Member

ijjk commented Apr 15, 2021

We've landed a patch for this and it should be available soon, will update here when it is!

@ijjk
Copy link
Member

ijjk commented Apr 16, 2021

The above mentioned patch is now available, please re-deploy your application and give it a try!

@sozonome
Copy link
Author

sozonome commented Jun 16, 2021

Hello @ijjk, thank you for the patch

unfortunately, it still happen in my other project
I opened a new issue here: #26200

@ijjk ijjk mentioned this issue Jun 16, 2021
2 tasks
kodiakhq bot pushed a commit to timneutkens/next.js that referenced this issue Aug 16, 2021
This adds tracing entrypoints directly after they have have been transpiled to allow us to trace before the webpack runtime has been added to the modules. This should allow for more accurate tracing of entrypoints and allow the trace step to be cached. 

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added


x-ref: vercel#24700
x-ref: vercel#26200
x-ref: vercel#23894
x-ref: vercel#25431
@balazsorban44
Copy link
Member

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants