nuxt / content

The file-based CMS for your Nuxt application, powered by Markdown and Vue components.
https://content.nuxt.com
MIT License
3.13k stars 627 forks source link

Document not found under production environment with other files in `/content` directory #2602

Closed qwerzl closed 7 months ago

qwerzl commented 7 months ago

Environment

❯ nuxi info
------------------------------
- Operating System: Linux
- Node Version:     v18.18.0
- Nuxt Version:     3.11.1
- CLI Version:      3.11.1
- Nitro Version:    2.9.5
- Package Manager:  npm@10.2.3
- Builder:          -
- User Config:      modules
- Runtime Modules:  @nuxt/content@2.12.1, @nuxt/ui@2.15.0
- Build Modules:    -
------------------------------

Reproduction

https://stackblitz.com/edit/github-xx74jl?file=app.vue

Describe the bug

If there are unrelated files in the content directory (even if they are not imported anywhere), Nuxt Content will show Document not found error in production.

In the reproduction, I've added content/bad.ts. Dev mode works without errors but the error occurs in production environment.

Additional context

No response

Logs

[nuxt] [request error] [unhandled] [500] Cannot read properties of undefined (reading '_path')
  at eval (./.output/server/chunks/runtime.mjs:8344:52)  
  at Array.find (<anonymous>)  
  at fetchDirConfig (./.output/server/chunks/runtime.mjs:8344:32)  
  at eval (./.output/server/chunks/runtime.mjs:8378:63)  
  at Array.reduce (<anonymous>)  
  at eval (./.output/server/chunks/runtime.mjs:8378:39)  
  at async Object.eval [as handler] (./.output/server/chunks/runtime.mjs:8709:21)  
  at async Object.eval [as handler] (./.output/server/chunks/runtime.mjs:3052:19)  
  at async Server.toNodeHandle (./.output/server/chunks/runtime.mjs:3318:7)