Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NEXT-1017] Intercepted routes: error on Vercel builds only #48406

Closed
1 task done
alex-ketch opened this issue Apr 15, 2023 · 4 comments · Fixed by #48451
Closed
1 task done

[NEXT-1017] Intercepted routes: error on Vercel builds only #48406

alex-ketch opened this issue Apr 15, 2023 · 4 comments · Fixed by #48451
Assignees
Labels
area: app App directory (appDir: true) bug Issue was opened via the bug report template. linear: next Confirmed issue that is tracked by the Next.js team.

Comments

@alex-ketch
Copy link

alex-ketch commented Apr 15, 2023

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
      Platform: darwin
      Arch: x64
      Version: Darwin Kernel Version 22.4.0: Mon Mar  6 21:00:17 PST 2023; root:xnu-8796.101.5~3/RELEASE_X86_64
    Binaries:
      Node: 18.15.0
      npm: 9.5.0
      Yarn: N/A
      pnpm: 8.1.0
    Relevant packages:
      next: 13.3.1-canary.7
      eslint-config-next: N/A
      react: 18.2.0
      react-dom: 18.2.0

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

App directory (appDir: true)

Link to the code that reproduces this issue

https://intercepted-modals.vercel.app

To Reproduce

Clone and deploy the following project to Vercel: https://github.com/alex-ketch/intercepted-modals.
An existing deployment can be seen here: https://intercepted-modals.vercel.app

404 Error:

  • Open https://intercepted-modals.vercel.app
  • Click "intercepting-parallel-modal" link
  • Click on any of the links listed under "Feed for userId"
  • See 404 error
  • Refresh the page. Content of photo detail page is present.

500 Error:

  • Open https://intercepted-modals.vercel.app
  • Click "dynamic-sibling-route" link
  • Click on any of the links listed under "Feed for userId"
  • See 500 error
  • Refresh the page. 500 error is still present.

Describe the Bug

When a project using intercepted routes is deployed to Vercel, a runtime error is encountered when attempting to open the intercepted route. What makes it hard to debug is that this error is not present during local development builds, or vercel dev commands.

There are two similar scenarios which both cause errors:

  • 404 error for an intercepted route for a different path segment (e.g. from /intercepting-parallel-modal/userId intercepting intercepting-parallel-modal/photo/1)
  • 500 error for intercepted route for a the current path segment (e.g. from dynamic-sibling-route intercepting /dynamic-sibling-route/3)

The above linked reproduction repo is directly based on the e2e tests found here: https://github.com/vercel/next.js/tree/canary/test/e2e/app-dir/parallel-routes-and-interception/app/(group). I've added another use case of catching a dynamic path for the current path under the dynamic-sibling-route folder.

When attempting to visit the modal route a 404 error is shown, but no relevant logs are seen in Vercel.
When attempting to visit a route for a dynamic sibling route the following 500 error is logged.

Error: Cannot find module '/var/task/.next/server/app/(group)/dynamic-sibling-route/@modal/(.)/[id]/page.js'
Require stack:
- /var/task/node_modules/next/dist/server/require.js
- /var/task/node_modules/next/dist/server/next-server.js
- /var/task/___next_launcher.cjs
    at Module._resolveFilename (node:internal/modules/cjs/loader:1039:15)
    at mod._resolveFilename (/var/task/node_modules/next/dist/build/webpack/require-hook.js:23:32)
    at Module._load (node:internal/modules/cjs/loader:885:27)
    at Module.require (node:internal/modules/cjs/loader:1105:19)
    at require (node:internal/modules/cjs/helpers:103:18)
    at Object.requirePage (/var/task/node_modules/next/dist/server/require.js:134:12)
    at /var/task/node_modules/next/dist/server/load-components.js:51:73
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Object.loadComponentsImpl [as loadComponents] (/var/task/node_modules/next/dist/server/load-components.js:51:26)
    at async NextNodeServer.findPageComponentsImpl (/var/task/node_modules/next/dist/server/next-server.js:667:36) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/var/task/node_modules/next/dist/server/require.js',
    '/var/task/node_modules/next/dist/server/next-server.js',
    '/var/task/___next_launcher.cjs'
  ],
  page: '/dynamic-sibling-route/2'
}
RequestId: fda2079e-9e18-4eda-aae7-fea0407cb78b Error: Runtime exited with error: exit status 1
Runtime.ExitError

Thought I'd mentioned you @feedthejim since I noticed you were working on these features recently. Let me know if you need any further info in debugging this.

Expected Behavior

Should match behaviour seen in local development builds.
I.e. clicking on a link for an item in the feed should show contents of the detail view.

Which browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

Vercel

From SyncLinear.com | NEXT-1017

@alex-ketch alex-ketch added the bug Issue was opened via the bug report template. label Apr 15, 2023
@github-actions github-actions bot added the area: app App directory (appDir: true) label Apr 15, 2023
@feedthejim feedthejim added the linear: next Confirmed issue that is tracked by the Next.js team. label Apr 15, 2023
@feedthejim feedthejim changed the title Intercepted routes: error on Vercel builds only [NEXT-1017] Intercepted routes: error on Vercel builds only Apr 15, 2023
@feedthejim
Copy link
Contributor

will look into it

@feedthejim feedthejim self-assigned this Apr 15, 2023
@feedthejim
Copy link
Contributor

@alex-ketch it seems you're using the wrong syntax for intercepting routes. In your project the path is (.)/[id], whereas you should be using (.)[id]. There's a bug for that particular usecase though tracked in #48143

It's definitely curious that it works, will add an error for that.

@feedthejim
Copy link
Contributor

There was also a bug for the 404 issue which I just fixed now @alex-ketch thanks for reporting

timneutkens pushed a commit that referenced this issue Apr 17, 2023
This PR fixes a bug with interception where the rewritten path passed an
incorrect segment data on production, resulting in a 404.

The fix consists of moving the rewrite pre-processing step that rewrites
the dynamic segment from the originating path to when we actually
generate the rewrite. This is needed because that step does not run on
production. Now it does and signals correctly to the app-render that the
value for the segment can be determined from the path.

Also enables prod testing, which I had forgotten to enable.

<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation or adding/fixing Examples

- The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- Make sure the linting passes by running `pnpm build && pnpm lint`. See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature
request has been accepted for implementation before opening a PR. (A
discussion must be opened, see
https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added
(https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md



## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->

fix #48406
link NEXT-1017
@github-actions
Copy link
Contributor

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: app App directory (appDir: true) bug Issue was opened via the bug report template. linear: next Confirmed issue that is tracked by the Next.js team.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants