Skip to content

Server functions not working on Vercel on V. 12 #30601

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

Closed
CruelMoney opened this issue Oct 29, 2021 · 11 comments
Closed

Server functions not working on Vercel on V. 12 #30601

CruelMoney opened this issue Oct 29, 2021 · 11 comments
Labels
bug Issue was opened via the bug report template.

Comments

@CruelMoney
Copy link

CruelMoney commented Oct 29, 2021

What version of Next.js are you using?

12.0.1

What version of Node.js are you using?

14 with yarn workspaces

What browser are you using?

Firefox

What operating system are you using?

macOS

How are you deploying your application?

Vercel

Describe the Bug

After upgrading to v. 12.0.1 from 11, I'm seeing the following error on server-rendered pages or API endpoints:

2021-10-29T06:41:38.719Z	1b7c44bd-4566-4e9b-9bb6-4815b987e8ed	
ERROR	Error: Cannot find module '/var/task/node_modules/next/dist/server/next.js'. Please verify that the package.json has a valid "main" entry
    at tryPackage (internal/modules/cjs/loader.js:320:19)
    at Function.Module._findPath (internal/modules/cjs/loader.js:533:18)
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:875:27)
    at Function.Module._load (internal/modules/cjs/loader.js:745:27)
    at Module.require (internal/modules/cjs/loader.js:961:19)
    at require (internal/modules/cjs/helpers.js:92:18)
    at Object.<anonymous> (/var/task/node_modules/@sentry/nextjs/dist/utils/instrumentServer.js:7:14)
    at Module._compile (internal/modules/cjs/loader.js:1072:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
    at Module.load (internal/modules/cjs/loader.js:937:32) {  code: 'MODULE_NOT_FOUND',  path: '/var/task/node_modules/next/package.json',  requestPath: 'next'}

It seems to be on all pages that use server functions - so static pages work.

Expected Behavior

To have all pages render without errors.

To Reproduce

Upgrade project from 11.1.3 to 12.0.1. Deploy to Vercel and attempt to load a page that uses getServerSideProps.

The project works when building and running it locally.

@CruelMoney CruelMoney added the bug Issue was opened via the bug report template. label Oct 29, 2021
@CruelMoney CruelMoney changed the title SSR not working on Vercel on V. 12 Server functions not working on Vercel on V. 12 Oct 29, 2021
@CruelMoney
Copy link
Author

Sorry, I see this might be related to the Sentry module. Will try to remove sentry and see if it works.

@CruelMoney
Copy link
Author

Ok, my bad.. removing withSentryConfig from next.config.js fixed the issue. Closing now.

@AkashRajpurohit
Copy link

Hi @CruelMoney I am also using Sentry and facing this issue. How is removing withSentryConfig fixing this?
Is there any new method of adding your sentry config post Nextjs v12?

@ovidb
Copy link

ovidb commented Nov 4, 2021

@CruelMoney @AkashRajpurohit Have you find a workaround to using sentry with Next 12?

@brentkirkland
Copy link

@ovidb add outputFileTracing: false to your next config

@AkashRajpurohit
Copy link

The comment mentioned by @brentkirkland fixed for me as well @ovidb

@dcastil
Copy link

dcastil commented Nov 5, 2021

Linking to getsentry/sentry-javascript#4103 in case anyone searches for a canonical issue.

@ivolivares
Copy link

ivolivares commented Dec 9, 2021

4:30am 🕟

Thank you all for this thread, works for me too!!

@aalises
Copy link

aalises commented Dec 9, 2021

Thanks! disabling outputFileTracing also fixed the issue for me.

@curiousercreative
Copy link

Just to say the upstream bug has been fixed and you all should consider updating sentry packages and reverting this workaround.

@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 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template.
Projects
None yet
Development

No branches or pull requests

9 participants