question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

getStaticProps crashes on next 12.2.0 when building

See original GitHub issue

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System: Platform: darwin Arch: arm64 Version: Darwin Kernel Version 21.5.0: Tue Apr 26 21:08:37 PDT 2022; root:xnu-8020.121.3~4/RELEASE_ARM64_T6000 Binaries: Node: 18.2.0 npm: 8.5.5 Yarn: 1.22.19 pnpm: 7.3.0 Relevant packages: next: 12.2.0 eslint-config-next: 12.1.6 react: 18.1.0 react-dom: 18.1.0

What browser are you using? (if relevant)

not relevant

How are you deploying your application? (if relevant)

No response

Describe the Bug

Only when the export const getStaticProps = () => { ... } function is added, the pnpm build crashes displaying the following error.

Screen Shot 2022-06-29 at 09 33 05

Code

Screen Shot 2022-06-29 at 09 33 42
  • Note: fetcher is a custom wrapper for the native fetch API that nextjs pollyfills.

Expected Behavior

Build shouldn’t crash and getStaticProps should be working as expected

Link to reproduction

unable to reproduce

To Reproduce

  1. boot starter ts project
  2. install chakra ui and set it up
  3. add getStaticProps in any page
  4. run yarn build

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:3
  • Comments:15

github_iconTop GitHub Comments

8reactions
ShonFraziercommented, Jun 29, 2022

I first experienced a problem with 12.2.0 when our CI pipeline attempted to next start after a successful build. Here’s the error from the attempted launch:

Jun 29 04:52:44 ip-10-11-18-224 web: > @<redacted>@0.1.0 start
Jun 29 04:52:44 ip-10-11-18-224 web: > next start
Jun 29 04:52:44 ip-10-11-18-224 web: warn  - You are using a non-standard "NODE_ENV" value in your environment. This creates inconsistencies in the project and is strongly advised against. Read more: https://nextjs.org/docs/messages/non-standard-node-env
Jun 29 04:52:44 ip-10-11-18-224 web: warn  - You are using a non-standard "NODE_ENV" value in your environment. This creates inconsistencies in the project and is strongly advised against. Read more: https://nextjs.org/docs/messages/non-standard-node-env
Jun 29 04:52:44 ip-10-11-18-224 web: ready - started server on 0.0.0.0:8080, url: http://localhost:8080
Jun 29 04:52:44 ip-10-11-18-224 web: TypeError: Cannot convert undefined or null to object
Jun 29 04:52:44 ip-10-11-18-224 web: at Function.keys (<anonymous>)
Jun 29 04:52:44 ip-10-11-18-224 web: at NextNodeServer.getEdgeFunctions (/var/app/current/node_modules/next/dist/server/next-server.js:656:23)
Jun 29 04:52:44 ip-10-11-18-224 web: at NextNodeServer.generateCatchAllMiddlewareRoute (/var/app/current/node_modules/next/dist/server/next-server.js:991:22)
Jun 29 04:52:44 ip-10-11-18-224 web: at NextNodeServer.generateRoutes (/var/app/current/node_modules/next/dist/server/base-server.js:464:41)
Jun 29 04:52:44 ip-10-11-18-224 web: at new Server (/var/app/current/node_modules/next/dist/server/base-server.js:109:48)
Jun 29 04:52:44 ip-10-11-18-224 web: at new NextNodeServer (/var/app/current/node_modules/next/dist/server/next-server.js:62:9)
Jun 29 04:52:44 ip-10-11-18-224 web: at NextServer.createServer (/var/app/current/node_modules/next/dist/server/next.js:128:16)
Jun 29 04:52:44 ip-10-11-18-224 web: at async /var/app/current/node_modules/next/dist/server/next.js:137:31

Since that time, a new project, created with npx create-next-app@latest will not build, producing @AlvaroAquijeDiaz 's error message from above.

Reproducing this bug does not require step 2 above in 'To Reproduce"

Current workaround: specify "next": "12.1" in package.json

1reaction
jakobocommented, Sep 21, 2022

This appears fixed in 12.3.1. My .next/server/middleware-manifest.json was moved to version 2 when I ran next build after upgrading, and the file includes the functions block.

{
  "sortedMiddleware": [],
  "middleware": {},
  "functions": {},
  "version": 2
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Why does my next.js server crash and stop working whenever ...
Whenever I add getStaticProps() to my next.js page, here is what I always get and the server crashes together with it. $ npm...
Read more >
getStaticProps Data Fetching | NextJS Crash Course - YouTube
If you export an async function called getStaticProps from a page, Next.js will pre-render this page at build time using the props returned ......
Read more >
Data Fetching: getStaticProps - Next.js
Fetch data and generate static pages with `getStaticProps`. ... The data required to render the page is available at build time ahead of...
Read more >
@next/polyfill-nomodule: Versions | Openbase
Full version history for @next/polyfill-nomodule including change logs. ... build(cargo): fix turbopack + next-swc build: #43983; Align onRecoverableError ...
Read more >
Fetch Data in Next.js - Documentation - Prismic
Make queries to the Prismic API to get content into your Next.js ... Data is fetched on the server once at build time...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found