vercel / next.js

The React Framework
https://nextjs.org
MIT License
124.73k stars 26.62k forks source link

Intercepting routes does not work with dynamic routes #51414

Closed volnei closed 9 months ago

volnei commented 1 year ago

Verify canary release

Provide environment information

Operating System:
      Platform: darwin
      Arch: arm64
      Version: Darwin Kernel Version 22.4.0: Mon Mar  6 20:59:28 PST 2023; root:xnu-8796.101.5~3/RELEASE_ARM64_T6000
    Binaries:
      Node: 19.0.1
      npm: 9.4.0
      Yarn: 1.22.19
      pnpm: N/A
    Relevant packages:
      next: 13.4.5
      eslint-config-next: 13.4.5
      react: 18.2.0
      react-dom: 18.2.0
      typescript: 5.0.4

warn  - Latest canary version not detected, detected: "13.4.5", newest: "13.4.7-canary.0".
        Please try the latest canary version (`npm install next@canary`) to confirm the issue still exists before creating a new issue.
        Read more - https://nextjs.org/docs/messages/opening-an-issue
✨  Done in 2.32s.

Which area(s) of Next.js are affected? (leave empty if unsure)

App directory (appDir: true)

Link to the code that reproduces this issue or a replay of the bug

private

To Reproduce

Create a dynamic route [team] and a intercept route @[team].

Describe the Bug

When tryed to create a dynamic route using intercepting next throw an error.

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './server.edge' is not defined by "exports" in /Users/volnei/Projects/cursiva/node_modules/react-dom/package.json
    at new NodeError (node:internal/errors:393:5)
    at throwExportsNotFound (node:internal/modules/esm/resolve:292:9)
    at packageExportsResolve (node:internal/modules/esm/resolve:602:3)
    at resolveExports (node:internal/modules/cjs/loader:529:36)
    at Module._findPath (node:internal/modules/cjs/loader:569:31)
    at Module._resolveFilename (node:internal/modules/cjs/loader:981:27)
    at /Users/volnei/Projects/cursiva/node_modules/next/dist/server/require-hook.js:189:36
    at Module._load (node:internal/modules/cjs/loader:841:27)
    at Module.require (node:internal/modules/cjs/loader:1061:19)
    at require (node:internal/modules/cjs/helpers:103:18)
    at /Users/volnei/Projects/cursiva/node_modules/next/dist/server/app-render/app-render.js:978:37
    at /Users/volnei/Projects/cursiva/node_modules/next/dist/server/lib/trace/tracer.js:159:62
    at /Users/volnei/Projects/cursiva/node_modules/next/dist/server/lib/trace/tracer.js:117:36
    at NoopContextManager.with (/Users/volnei/Projects/cursiva/node_modules/@opentelemetry/api/build/src/context/NoopContextManager.js:25:19)
    at ContextAPI.with (/Users/volnei/Projects/cursiva/node_modules/@opentelemetry/api/build/src/api/context.js:60:46)
    at NoopTracer.startActiveSpan (/Users/volnei/Projects/cursiva/node_modules/@opentelemetry/api/build/src/trace/NoopTracer.js:65:31)
    at ProxyTracer.startActiveSpan (/Users/volnei/Projects/cursiva/node_modules/@opentelemetry/api/build/src/trace/ProxyTracer.js:36:24)
    at /Users/volnei/Projects/cursiva/node_modules/next/dist/server/lib/trace/tracer.js:106:107
    at NoopContextManager.with (/Users/volnei/Projects/cursiva/node_modules/@opentelemetry/api/build/src/context/NoopContextManager.js:25:19)
    at ContextAPI.with (/Users/volnei/Projects/cursiva/node_modules/@opentelemetry/api/build/src/api/context.js:60:46)
    at NextTracerImpl.trace (/Users/volnei/Projects/cursiva/node_modules/next/dist/server/lib/trace/tracer.js:106:32)
    at /Users/volnei/Projects/cursiva/node_modules/next/dist/server/lib/trace/tracer.js:159:31
    at wrappedRender (/Users/volnei/Projects/cursiva/node_modules/next/dist/server/app-render/app-render.js:1025:62)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
}

Expected Behavior

Works like intercepting routes expected.

Which browser are you using? (if relevant)

Chrome

How are you deploying your application? (if relevant)

Vercel

alserembani94 commented 1 year ago

I might want to add a bit of context of how I get the same error with intercepting routes using dynamic routes.

Provide environment information

Operating system:
    System Version: macOS 14.0 (23A5276g)
    Kernel Version: Darwin 23.0.0
    Arch: arm64
Binaries:
    Node: 16.20.1
    npm: 8.19.4
    yarn: 1.22.19
    pnpm: 7.12.2
Relevant packages:
    next: 13.4.7
    eslint-config-next: 13.4.7
    react: 18.2.0
    react-dom: 18.2.0
    typescript: 5.1.5

Which area(s) of Next.js are affected? (leave empty if unsure)

App Directory

Link to the code that reproduces this issue or a replay of the bug

https://github.com/alserembani94/atifaimandev-v4/blob/dev/next.config.js

You can clone, and uncomment the i18n to replay the bug

To Reproduce

I just add i18n configuration in next.config.js, while having app/[lang] directory. Then, I get the error.

Describe the bug

I already configure the dynamic route app/[lang] to handle i18n routing. I just want to add this configuration inside next.config.js that should do route interception. However, I got this error instead when I try to run the project by running the following command:

pnpm dev

And this is the error:

- error Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './server.edge' is not defined by "exports" in /Users/alserembani/alserembani/atifaimandev-v4/node_modules/.pnpm/next@13.4.7_biqbaboplfbrettd7655fr4n2y/node_modules/react-dom/package.json
    at new NodeError (node:internal/errors:387:5)
    at throwExportsNotFound (node:internal/modules/esm/resolve:365:9)
    at packageExportsResolve (node:internal/modules/esm/resolve:649:3)
    at resolveExports (node:internal/modules/cjs/loader:556:36)
    at Function.Module._findPath (node:internal/modules/cjs/loader:596:31)
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:1014:27)
    at /Users/alserembani/alserembani/atifaimandev-v4/node_modules/.pnpm/next@13.4.7_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/server/require-hook.js:189:36
    at Function.Module._load (node:internal/modules/cjs/loader:873:27)
    at Module.require (node:internal/modules/cjs/loader:1100:19)
    at require (node:internal/modules/cjs/helpers:108:18)
    at /Users/alserembani/alserembani/atifaimandev-v4/node_modules/.pnpm/next@13.4.7_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/server/app-render/app-render.js:980:37
    at /Users/alserembani/alserembani/atifaimandev-v4/node_modules/.pnpm/next@13.4.7_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/server/lib/trace/tracer.js:159:62
    at /Users/alserembani/alserembani/atifaimandev-v4/node_modules/.pnpm/next@13.4.7_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/server/lib/trace/tracer.js:117:36
    at NoopContextManager.with (/Users/alserembani/alserembani/atifaimandev-v4/node_modules/.pnpm/next@13.4.7_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:7057)
    at ContextAPI.with (/Users/alserembani/alserembani/atifaimandev-v4/node_modules/.pnpm/next@13.4.7_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:516)
    at NoopTracer.startActiveSpan (/Users/alserembani/alserembani/atifaimandev-v4/node_modules/.pnpm/next@13.4.7_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:18086)
    at ProxyTracer.startActiveSpan (/Users/alserembani/alserembani/atifaimandev-v4/node_modules/.pnpm/next@13.4.7_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:18847)
    at /Users/alserembani/alserembani/atifaimandev-v4/node_modules/.pnpm/next@13.4.7_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/server/lib/trace/tracer.js:106:107
    at NoopContextManager.with (/Users/alserembani/alserembani/atifaimandev-v4/node_modules/.pnpm/next@13.4.7_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:7057)
    at ContextAPI.with (/Users/alserembani/alserembani/atifaimandev-v4/node_modules/.pnpm/next@13.4.7_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:516)
    at NextTracerImpl.trace (/Users/alserembani/alserembani/atifaimandev-v4/node_modules/.pnpm/next@13.4.7_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/server/lib/trace/tracer.js:106:32)
    at /Users/alserembani/alserembani/atifaimandev-v4/node_modules/.pnpm/next@13.4.7_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/server/lib/trace/tracer.js:159:31
    at wrappedRender (/Users/alserembani/alserembani/atifaimandev-v4/node_modules/.pnpm/next@13.4.7_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/server/app-render/app-render.js:1028:62)
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {
  digest: undefined
}

Expected Behavior

Works with i18n routing as expected.

Which browser are you using? (if relevant)

Chrome, Arc

How are you deploying your application? (if relevant)

Vercel

timsuchanek commented 1 year ago

Same here. Took me a couple of hours to find. Commenting out the i18n in my next.config.js makes it work. Can also be reproduced in https://github.com/vercel-labs/nextgram

timsuchanek commented 1 year ago

As i18n is enabled in the default starter, imo this is an urgent bug, as many people will run into this when trying out intercepting routes.

hadnet commented 11 months ago

Same thing with me, it doesn't work using i18n enabled, i'm using the app router and the intercepting routes is completely ignored. My project needs i18n, so WTF Vercel?

hadnet commented 10 months ago

That’s why Vercel is highly criticized in the market when you take a look at their products. What’s worse, they’re not honest enough to clarify. I think the Vercel CEO is falling short in many ways. It’s a shame.

balazsorban44 commented 9 months ago

@hadnet I kindly ask you to follow our code of conduct when commenting. Frustration is perfectly fine, but your comments do not contribute to resolving the issue. Thanks for understanding!

If you don't have a reproduction, the best contribution is to :+1: the original post so that we know it needs to be prioritized. I'm looking into this now. The reason it might have been initially ignored is that the OP did not include a reproduction.

balazsorban44 commented 9 months ago

I was checking https://github.com/vercel/next.js/issues/51414#issuecomment-1615085698 but I cannot see intercepting routes in that reproduction, so anyone having the same issue, could you please link to one? :pray:

github-actions[bot] commented 9 months ago

We cannot recreate the issue with the provided information. Please add a reproduction in order for us to be able to investigate.

Why was this issue marked with the please add a complete reproduction label?

To be able to investigate, we need access to a reproduction to identify what triggered the issue. We prefer a link to a public GitHub repository (template for App Router, template for Pages Router), but you can also use these templates: CodeSandbox: App Router or CodeSandbox: Pages Router.

To make sure the issue is resolved as quickly as possible, please make sure that the reproduction is as minimal as possible. This means that you should remove unnecessary code, files, and dependencies that do not contribute to the issue. Ensure your reproduction does not depend on secrets, 3rd party registries, private dependencies, or any other data that cannot be made public. Avoid a reproduction including a whole monorepo (unless relevant to the issue). The easier it is to reproduce the issue, the quicker we can help.

Please test your reproduction against the latest version of Next.js (next@canary) to make sure your issue has not already been fixed.

If you cannot create a clean reproduction, another way you can help the maintainers' job is to pinpoint the canary version of next that introduced the issue. Check out our releases, and try to find the first canary release that introduced the issue. This will help us narrow down the scope of the issue, and possibly point to the PR/code change that introduced it. You can install a specific version of next by running npm install next@<version>.

I added a link, why was it still marked?

Ensure the link is pointing to a codebase that is accessible (e.g. not a private repository). "example.com", "n/a", "will add later", etc. are not acceptable links -- we need to see a public codebase. See the above section for accepted links.

What happens if I don't provide a sufficient minimal reproduction?

Issues with the please add a complete reproduction label that receives no meaningful activity (e.g. new comments with a reproduction link) are automatically closed and locked after 30 days.

If your issue has not been resolved in that time and it has been closed/locked, please open a new issue with the required reproduction.

I did not open this issue, but it is relevant to me, what can I do to help?

Anyone experiencing the same issue is welcome to provide a minimal reproduction following the above steps. Furthermore, you can upvote the issue using the :+1: reaction on the topmost comment (please do not comment "I have the same issue" without reproduction steps). Then, we can sort issues by votes to prioritize.

I think my reproduction is good enough, why aren't you looking into it quicker?

We look into every Next.js issue and constantly monitor open issues for new comments.

However, sometimes we might miss one or two due to the popularity/high traffic of the repository. We apologize, and kindly ask you to refrain from tagging core maintainers, as that will usually not result in increased priority.

Upvoting issues to show your interest will help us prioritize and address them as quickly as possible. That said, every issue is important to us, and if an issue gets closed by accident, we encourage you to open a new one linking to the old issue and we will look into it.

Useful Resources

kachkaev commented 9 months ago

👋 @balazsorban44! There is a reproduction of a similar case with intercepting routes in https://github.com/vercel/next.js/issues/53170. The title of the issue is different, but it might have the same root cause. You can also find a few incoming links below my report. I guess there is a bunch of issues originating from a single bug, which can potentially be solved all at once.

Screenshot 2023-12-11 at 14 05 53

balazsorban44 commented 9 months ago

Thanks @kachkaev! I'm looking into that issue right now. I'll be closing this one manually, if anyone having the same issue and has a complete but minimal reproduction with next@canary, feel free to open a new issue, and we will follow up!

github-actions[bot] commented 8 months ago

This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.