next.js: getStaticProps crashes on next 12.2.0 when building
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.
- Note: Using @chakra-ui

Code
- Note:
fetcheris a custom wrapper for the nativefetchAPI that nextjs pollyfills.
Expected Behavior
Build shouldn’t crash and getStaticProps should be working as expected
Link to reproduction
unable to reproduce
To Reproduce
- boot starter ts project
- install chakra ui and set it up
- add
getStaticPropsin any page - run
yarn build
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 3
- Comments: 17 (2 by maintainers)
Commits related to this issue
- deps: Pins next.js to 12.1 pending fix ref - https://github.com/vercel/next.js/issues/38153#issuecomment-1253135771 — committed to taskless/taskless by jakobo 2 years ago
I first experienced a problem with 12.2.0 when our CI pipeline attempted to
next startafter a successful build. Here’s the error from the attempted launch:Since that time, a new project, created with
npx create-next-app@latestwill 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.jsonThis appears fixed in
12.3.1. My.next/server/middleware-manifest.jsonwas moved to version 2 when I rannext buildafter upgrading, and the file includes thefunctionsblock.I’m not an expert in this code, but I wonder if perhaps:
functionsproperty to the middleware manifest (.next/server/middleware-manifest.json)functionsproperty to the middleware manifest.Someone with more knowledge of the code might be able to verify if these theories are true.
In any case, it does seem to work with the latest version on
canaryright now in git, so something appears to have fixed the problem.