withastro / astro

The web framework for content-driven websites. ⭐️ Star to support our work!
https://astro.build
Other
46.93k stars 2.49k forks source link

`RenderUndefinedEntryError` error when editing config with the `--force` content layer flag #12456

Open HiDeoo opened 5 days ago

HiDeoo commented 5 days ago

Astro Info

Astro                    v5.0.0-beta.8
Node                     v18.20.3
System                   Linux (x64)
Package Manager          npm
Output                   static
Adapter                  none
Integrations             none

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

Using content layer and developing a remark plugin inlined in my Astro config file, I'm running the npm run dev -- --force command to force the Astro dev server to restart when editing my plugin and having it run every time as the cache is cleared every time.

Reproduction steps:

  1. Open the linked repro
  2. Ctrl + C to stop the server
  3. Run the npm run dev -- --force command
  4. Edit the configuration and save the file (it could be an edit to the remark plugin or even to a comment in the config file)

The The collection "posts" does not exist. Please ensure it is defined in your content config. message is logged 1 or multiple times and then the following error is thrown:

[ERROR] [RenderUndefinedEntryError] 
  Hint:
    Check if the entry is undefined before passing it to `render()`
  Error reference:
    https://docs.astro.build/en/reference/errors/render-undefined-entry-error/
  Stack trace:
    at /home/projects/mklirypram.github/node_modules/astro/dist/core/errors/errors.js:17:5
    [...] See full stack trace in the browser, or rerun with --verbose.

Note that the error can also happens sometime without even editing the config file but it seems to recover somehow.

What's the expected result?

I'm expecting the server to restart and my plugin to be re-run without any errors.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-qstek1?file=astro.config.mjs

Participation