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.

Multiple Optional Catchall Routes with overlapping patterns fails to correctly fall-back in dev mode

See original GitHub issue

Bug report

Describe the bug

While next is in dev mode, it fails to build appropriate catchall route when multiple catchalls exist with overlapping patterns. For example, a page at pages/[[...foo]].js/ will not be built if pages/[bar]/[[...bazz.js]] exists, until first navigating to the homepage / to force a build of [[...foo]]

To Reproduce

Created an example branch with this behavior https://github.com/brandondc741/next-catchall-route-bug

Repro steps are located in https://github.com/brandondc741/next-catchall-route-bug/blob/master/HOW_TO_REPLICATE_ISSUE.md

  1. npx next dev
  2. First visit /foo/root
  3. Observe 404
  4. visit /
  5. Observe page renders, [[…slug]] builds
  6. visit /foo/root
  7. Observe page now renders

Expected behavior

In dev mode, when next.js is given the path /foo/root it should

  1. Attempt to render pages/[firstSegment]/[[...nestedSlug]].js
  2. Fall-back to attempting to render [[...slug]].js

System information

  • OS: macOS
  • Version of Next.js: 9.5.3
  • Version of Node.js: 12.18.0

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:2
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
maidi29commented, Sep 23, 2022

I’m experiencing a similar issue. I have the following structure

pages/foo/[…slug].tsx pages/[[…slug]].tsx

In the catchAllRoute of [[…slug]].tsx in the root, there exists a page foo/xy that is not covered by the filter in getStaticPaths of the […slug].tsx inside foo. In the dev mode the application runs into an error calling foo/xy. With build and start it works fine on the first call but when revalidate fires, the error is still there.

We managed to identify the possible cause of this bug: When running in the dev mode getStaticPaths is “ignored” because there is no static generation --> the call arrives in [slug].tsx inside foo and jumps into getStaticProps and tries to render the page from there without looking it up in [[…slug]].tsx in the root. While building, getStaticPaths is taken into account and everything renders as it should. Then (in our case) revalidate fires and again we directly jump into getStaticProps of the […slug].tsx inside foo.

A fix of this bug should consider the overlapping catchAllRoutes based on their filter in getStaticPaths also in revalidate and dev mode.

1reaction
fakeharahmancommented, Oct 2, 2020

Hey, I am new to open source. Can I try to work on this issue?

Read more comments on GitHub >

github_iconTop Results From Across the Web

NextJS Optional catch all routes not working when deployed
The issue is, the optional catch-all are not workink properly whenever the pages are statically generated. Ex: productId/contentOne does not ...
Read more >
Supplemental Document: Log Messages Reference - AskF5
The Scrubber Route Domain (%s) has a destination IP (%s) that overlaps with (%s). 01071ceb, Operation failed for CA bundle manager %s due...
Read more >
Configuring and managing networking Red Hat Enterprise ...
Configuring multiple Ethernet interfaces using a single connection profile ... Optional: Configure the behavior if NetworkManager does not receive an IPv4 ...
Read more >
8. Configuration Reference — BIND 9 9.18.8 documentation
Similarly, the listen-on option causes the server to refuse queries on any of ... BIND to fall back to normal (non-minimized) query mode...
Read more >
Cisco Collaboration System 12.x Solution Reference Network ...
Do not assign a single route filter to too many route patterns. ... selected so that it does not cause overlap with any...
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