Repository navigation
Description
Verify canary release
- I verified that the issue exists in the latest Next.js canary release
Provide environment information
Operating System:
Platform: linux
Arch: x64
Version: #1 SMP Fri Apr 2 22:23:49 UTC 2021
Binaries:
Node: 18.2.0
npm: 8.9.0
Yarn: 1.22.19
pnpm: 6.11.0
Relevant packages:
next: 12.1.7-canary.48
react: 18.2.0
react-dom: 18.2.0
What browser are you using? (if relevant)
Chrome, but n/a
How are you deploying your application? (if relevant)
n/a
Describe the Bug
#16874 is still impacting users. I have a repro! If the network request to /_next/static/development/_devPagesManifest.json fails for any reason, the Next.js dev application crashes with:
Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'includes')
at resolveDynamicRoute (router.js?8684:1314:16)
at _callee$ (router.js?8684:969:31)
at tryCatch (runtime.js?ecd4:45:16)
at Generator.invoke [as _invoke] (runtime.js?ecd4:274:1)
at prototype.<computed> [as next] (runtime.js?ecd4:97:1)
at asyncGeneratorStep (_async_to_generator.js?0e30:23:1)
at _next (_async_to_generator.js?0e30:12:1)
Expected Behavior
Next.js should be resilient to that manifest failing to load.
I took a dive into the source code and there are some spicy TypeScript shenanigans happening 😄. And some TODOs about handling this correctly! #38046 is a draft PR showing what I'd suggest doing to resolve this issue.
- The crash is coming from inside the framework, on
if (pages.includes(fsPathname)) pagesis a parameter ofresolveRewrites- In calls to
resolveRewrites,pagescomes fromthis.pageLoader.getPageList() getPageListdoesn't properly handle the case offetch(.../_next/static/development/_devPagesManifest.json)failing:return this.promisedDevPagesManifest!has a// TODO Remove this assertion as this could be undefinedcomment
Link to reproduction
https://stackblitz.com/edit/vercel-next-js-flnphe?file=pages%2Findex.tsx
(really, any Next.js app with a Link can demonstrate this issue)
To Reproduce
- Start any Next.js app in development mode
- Add a
<Link>somewhere on the page - Visit localhost:3000 (or equivalent) in Chrome (or equivalent)
- In the network tab, right click on the _devPagesManifest.json request and select Block request url
- Refresh the page
Step 3 is the easiest way to simulate any of the reasons why that URL wouldn't be accessible that are mentioned in #16874. Apparently nginx configurations are more common culprits. Anecdotally I think I've seen this on CI runs that have flaky network layers (both GitHub Actions and CircleCI).
Activity
fix: improve logging for _devPagesManifest.json loading failures (#38046
github-actions commentedon Sep 7, 2022
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.