vercel / vercel/next.js

`next build` fails while prerendering internal /_global-error route that does not exist in the app

Open
#87,719 17 comments 3 reactions 1 assignee View on GitHub

@icyJoseph is already working on this.

Since Dec 23, 2025.

create-next-app
Dominant language
JavaScript
Stars
142k
Forks
32.4k
Avg merge
2d 14h
Merged PRs (30d)
351

Description

Link to the code that reproduces this issue

https://github.com/bnjmnjrk/next-build-bug

To Reproduce
  1. run: pnpx next build
Current vs. Expected behavior

I expected the build to be successful, but instead I got:

▲ Next.js 16.1.1 (Turbopack)

Creating an optimized production build ...
✓ Compiled successfully in 1622.4ms
✓ Finished TypeScript in 1291.8ms
✓ Collecting page data using 7 workers in 344.7ms
Error occurred prerendering page "/global-error". Read more: https://nextjs.org/docs/messages/prerender-error
Error [InvariantError]: Invariant: Expected workUnitAsyncStorage to have a store. This is a bug in Next.js.
at M (.next/server/chunks/ssr/[root-of-the-server]__03cd63cf.
.js:1:95629)
at bM (.next/server/chunks/ssr/[root-of-the-server]__03cd63cf._.js:4:7728)
Export encountered an error on /_global-error/page: /_global-error, exiting the build.
⨯ Next.js build worker exited with code: 1 and signal: null

Provide environment information
os: arch-linux
node: v24.4.1
pnpm: 10.26.1
Which area(s) are affected? (Select all that apply)

create-next-app

Which stage(s) are affected? (Select all that apply)

next build (local)

Additional context

project setup was: pnpm create next-app@latest my-app --yes

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.