-
-
Notifications
You must be signed in to change notification settings - Fork 623
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
Dynamic pages with query in layout can fail silently, causing hard-to-debug errors during generate #2682
Comments
You can enable export default defineNuxtConfig({
nitro: {
prerender: {
failOnError: true
}
}
}) |
Thanks for that, @farnabaz -- I just tried it in the test project linked above, and unfortunately it does not show any new errors or tracebacks or anything helpful at all. I still just get the unexplained 404s during |
As I checked your content, Seems that you have some links to non-existed pages in your content. You have a lint to |
That's a tag; the tag pages are auto-generated by |
Indeed it is a tag, but inside layout you are trying to fetch the content based on the |
Yes, I think you are right -- as I mentioned in the bug report:
But the reason I created this bug report is that it is nearly impossible to figure out what needs to be done based on the error messages shown during My hope is that by showing this example, someone could trap the error at a better place and show something useful to help users. |
Perhaps the module could log some warnings in the console in Dev mode to warn about generation issue. |
Yes, that might help -- but I don't actually see anything wrong in dev mode; there the query seems to work ok (at least it does not throw; maybe it's returning an empty result?) |
If you look at the network tab in dev mode you will find 404 api calls. In generation, module tries to generate those api calls which results 404 error and fail in generation. |
I have the same issue with some malformed markdown content and it is really annoying because the continuous integration (gitlab-ci) does not detect that the generate command had errors ....
I tried the nitro prerender config in nuxt.config.ts but the CI still passed. I saw that in previous version of Nuxt (V2) there was a command arg |
Environment
Reproduction
Minimal reproducer is at https://github.com/garyo/nuxt-bug-report1
To repro, clone that repo,
pnpm install
, andpnpm generate
(or use yarn/npm). You will see errors.Describe the bug
This example shows a hard-to-debug issue with Nuxt content query and SSR static site generation.
The problem is that the dynamically generated
pages/articles/tags/[tag].vue
page slug, use theNuxtLayout
default layout. That layout runs a content query in a script:For some reason, that script causes the prerender to fail silently, such that those dynamically rendered tags pages return 404s (or actually the pre-generated query results return 404s):
The fix is to have the dyamic pages use a simpler layout that doesn't do this query. But the bug I'm reporting is that the failures during prerender are silent (except for the 404s reported above) so it is very nearly impossible to debug. Took me many hours to even find out it was the layout that was responsible. It seems likely the query is failing but the error is silently discarded; it would be much better if the actual failure were reported when it happens, so the developer can see what query failed with a pointer to their file & line number.
Additional context
No response
Logs
No response
The text was updated successfully, but these errors were encountered: