close
The Wayback Machine - https://web.archive.org/web/20220422161215/https://github.com/blitz-js/blitz/issues/2820
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

Duplicate page name error display needs improved #2820

Closed
3 tasks
flybayer opened this issue Oct 7, 2021 · 5 comments · Fixed by #2823
Closed
3 tasks

Duplicate page name error display needs improved #2820

flybayer opened this issue Oct 7, 2021 · 5 comments · Fixed by #2823

Comments

@flybayer
Copy link
Member

@flybayer flybayer commented Oct 7, 2021

What is the problem?

As you can see in the below log, it's hard to read and parse the error message.

  • It shouldn't have a stack trace
  • It should list all duplicate routes if there are more than one
  • It should have a more easy to read message like below
ready - started server on 0.0.0.0:3000, url: http://localhost:3000
info  - Loaded env from /Users/b/c/ahts/homeschool-boss/.env.local
info  - Loaded env from /Users/b/c/ahts/homeschool-boss/.env
info  - Using webpack 5. Reason: Enabled by default https://nextjs.org/docs/messages/webpack5

The page component is named "ShowOrderPage" on the following routes 

    /admin/orders/[orderId]
    /orders/[orderId]
    /custom/orders/[orderId]

The page component must have a unique name across all routes, so change the component names so they are all unique.

Error: Duplicate Page Name

Paste all your error logs here:

ready - started server on 0.0.0.0:3000, url: http://localhost:3000
info  - Loaded env from /Users/b/c/ahts/homeschool-boss/.env.local
info  - Loaded env from /Users/b/c/ahts/homeschool-boss/.env
info  - Using webpack 5. Reason: Enabled by default https://nextjs.org/docs/messages/webpack5
Error: The page component is named "ShowOrderPage" on both the /admin/orders/[orderId] and /orders/[orderId] routes. The page component must have a unique name across all routes, so change the component name on one of those routes to avoid conflict.
    at /Users/b/c/ahts/homeschool-boss/node_modules/next/dist/build/routes.js:193:23
    at Array.filter (<anonymous>)
    at dedupeBy (/Users/b/c/ahts/homeschool-boss/node_modules/next/dist/build/routes.js:182:16)
    at generateManifest (/Users/b/c/ahts/homeschool-boss/node_modules/next/dist/build/routes.js:200:37)
    at Object.saveRouteManifest (/Users/b/c/ahts/homeschool-boss/node_modules/next/dist/build/routes.js:116:47)
    at async DevServer.prepare (/Users/b/c/ahts/homeschool-boss/node_modules/next/dist/server/dev/next-dev-server.js:239:9)
    at async /Users/b/c/ahts/homeschool-boss/node_modules/next/dist/cli/next-dev.js:120:9

What are detailed steps to reproduce this?

  1. Add three pages at different urls, with component name of Page or anything else, as long as all pages have same name
  2. Run blitz dev

How to fix

Here's the current code for this: https://github.com/blitz-js/blitz/blob/canary/nextjs/packages/next/build/routes.ts#L227-L232

Essentially solution is instead of throwing full error message, first log pretty error with baseLogger.error(), then throw error with "Duplicate Page Name". But first delete error.stack before throwing so it won't log.

@flybayer flybayer added status/ready-to-work-on good first issue kind/bad-experience labels Oct 7, 2021
@blitzjs-bot blitzjs-bot added this to Ready to Work On in Dashboard Oct 7, 2021
@blitzjs-bot blitzjs-bot removed the status/ready-to-work-on label Oct 8, 2021
@blitzjs-bot blitzjs-bot moved this from Ready to Work On to In Progress in Dashboard Oct 8, 2021
@ajwgeek
Copy link

@ajwgeek ajwgeek commented Oct 10, 2021

Would it be possible to handle this error in a way that would keep the development server running? When I am making new pages, I frequently copy and paste an existing page. This usually causes the development server to crash:

Listening on 127.0.0.1:9181.
info  - Using webpack 5. Reason: Enabled by default https://nextjs.org/docs/messages/webpack5
warn  - You have enabled experimental feature(s).
warn  - Experimental features are not covered by semver, and may cause unexpected or broken application behavior. Use them at your own risk.

Error: The page component is named "UpdateFAQ" on both the /cms/frequentlyAskedQuestion/[id] and /cms/blah/create routes. The page component must have a unique name across all routes, so change the component name on one of those routes to avoid conflict.
    at /workspaces/monorepo/node_modules/next/dist/build/routes.js:193:23
    at Array.filter (<anonymous>)
    at dedupeBy (/workspaces/monorepo/node_modules/next/dist/build/routes.js:182:16)
    at generateManifest (/workspaces/monorepo/node_modules/next/dist/build/routes.js:200:37)
    at Object.saveRouteManifest (/workspaces/monorepo/node_modules/next/dist/build/routes.js:116:47)
    at async DevServer.prepare (/workspaces/monorepo/node_modules/next/dist/server/dev/next-dev-server.js:239:9)
    at async /workspaces/monorepo/node_modules/next/dist/cli/next-dev.js:120:9
node:internal/process/promises:246
          triggerUncaughtException(err, true /* fromPromise */);
          ^

[UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "1".] {
  code: 'ERR_UNHANDLED_REJECTION'
}
@ajwgeek ➜ /workspaces/monorepo (canary ✗) $ 

@lucas-barros
Copy link

@lucas-barros lucas-barros commented Oct 12, 2021

Hi @flybayer may I work on this issue?

@blitzjs-bot blitzjs-bot moved this from In Progress to Assigned in Dashboard Oct 12, 2021
@abuuzayr
Copy link
Collaborator

@abuuzayr abuuzayr commented Oct 12, 2021

hey @lucas-barros thank you, i have assigned you, do let us know if you need any help with this issue!

@p-siriphanthong
Copy link
Contributor

@p-siriphanthong p-siriphanthong commented Oct 12, 2021

I already open the PR for this issue 4 days ago. Anyone, please review.

@beerose
Copy link
Member

@beerose beerose commented Oct 12, 2021

I already open the PR for this issue 4 days ago. Anyone, please review.

Hey @p-siriphanthong, I'm sorry for the delay. I'll review it today.

@blitzjs-bot blitzjs-bot moved this from Assigned to Done in Dashboard Oct 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging a pull request may close this issue.

7 participants