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

fix(nuxt): log errors thrown when booting the nuxt app #19187

Merged
merged 3 commits into from
Feb 21, 2023

Conversation

danielroe
Copy link
Member

πŸ”— Linked issue

resolves #19162

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

This ensures we don't swallow plugin errors, in development mode at least. We could also consider adding a warning if user doesn't register their own handler?

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@codesandbox
Copy link

codesandbox bot commented Feb 21, 2023

CodeSandbox logoCodeSandbox logoΒ  Open in CodeSandbox Web Editor | VS Code | VS Code Insiders

@pi0
Copy link
Member

pi0 commented Feb 21, 2023

Nice find. Since we don't suppress other errors from console by default why not also doing for production?

@danielroe
Copy link
Member Author

We do suppress errors in other places (in that we require users to handle them), specifically when it comes to universal router errors and in useAsyncData/useFetch. But in this case I am very persuadable.

@danielroe danielroe requested a review from pi0 February 21, 2023 11:28
@danielroe danielroe changed the title fix(nuxt): log plugin errors in development fix(nuxt): log errors thrown when booting the nuxt app Feb 21, 2023
packages/nuxt/src/app/nuxt.ts Outdated Show resolved Hide resolved
@danielroe danielroe merged commit 7479d46 into main Feb 21, 2023
@danielroe danielroe deleted the fix/log-dev-errors branch February 21, 2023 15:06
@danielroe danielroe mentioned this pull request Feb 27, 2023
@devilmark84
Copy link

Hello, I've just installed the new 3.2.3 version of Nuxt and now this happens when a page is not found.

[nuxt] error caught during app initialization H3Error: Page not found: /robots.txt                                                                                          11:13:52
    at Module.createError (file:///Users/marco/Desktop/nuxt-bootstrap/node_modules/h3/dist/index.mjs:128:15)
    at /Users/marco/Desktop/nuxt-bootstrap/node_modules/nuxt/dist/pages/runtime/plugins/router.mjs:141:113
    at triggerAfterEach (file:///Users/marco/Desktop/nuxt-bootstrap/node_modules/vue-router/dist/vue-router.mjs:3306:13)
    at file:///Users/marco/Desktop/nuxt-bootstrap/node_modules/vue-router/dist/vue-router.mjs:3209:13
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async /Users/marco/Desktop/nuxt-bootstrap/node_modules/nuxt/dist/pages/runtime/plugins/router.mjs:157:7
    at async createNuxtAppServer (/Users/marco/Desktop/nuxt-bootstrap/node_modules/nuxt/dist/app/entry.mjs:30:7)
    at async default (file:///Users/marco/Desktop/nuxt-bootstrap/node_modules/@nuxt/vite-builder/dist/runtime/vite-node.mjs:27:18)
    at async Object.renderToString (file:///Users/marco/Desktop/nuxt-bootstrap/node_modules/vue-bundle-renderer/dist/runtime.mjs:172:19)
    at async file:///Users/marco/Desktop/nuxt-bootstrap/.nuxt/dev/index.mjs:791:21 {
  statusCode: 404,
  fatal: false,
  unhandled: false,
  statusMessage: 'Page not found: /robots.txt',
  __nuxt_error: true
}

Is this behavior what you wanted? 🧐 How can I suppress these errors or catch them?

Thank you

@pi0
Copy link
Member

pi0 commented Mar 8, 2023

I also spotted same issue. I guess we might apply a filter to hide internal type of errors (i guess we added a field for it /cc @danielroe )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Onclick will not work if certain files are in the plugin folder
3 participants