Skip to content

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

Open
@bits-by-brandon

Description

@bits-by-brandon

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Linking and NavigatingRelated to Next.js linking (e.g., <Link>) and navigation.good first issueEasy to fix issues, good for newcomers

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions