Routing error in dev mode: TypeError: Cannot read property 'includes' of undefined (take two) #38047
Closed
1 task done
Labels
bug
Issue was opened via the bug report template.
Verify canary release
Provide environment information
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: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.
if (pages.includes(fsPathname))
pages
is a parameter ofresolveRewrites
resolveRewrites
,pages
comes fromthis.pageLoader.getPageList()
getPageList
doesn'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 undefined
commentLink 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
<Link>
somewhere on the pageStep 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).
The text was updated successfully, but these errors were encountered: