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

RenderUndefinedEntryError from dev server #12773

Closed
1 task
andersk opened this issue Dec 17, 2024 · 9 comments · Fixed by #12818
Closed
1 task

RenderUndefinedEntryError from dev server #12773

andersk opened this issue Dec 17, 2024 · 9 comments · Fixed by #12818
Assignees
Labels
- P4: important Violate documented behavior or significantly impacts performance (priority) feat: content layer Related to the Content Layer feature (scope)

Comments

@andersk
Copy link
Contributor

andersk commented Dec 17, 2024

What version of starlight are you using?

0.30.2

What version of astro are you using?

5.0.9

What package manager are you using?

npm

What operating system are you using?

Linux

What browser are you using?

Chromium, Firefox

Describe the Bug

The official StackBlitz template linked from getting started shows an error page:

RenderUndefinedEntryError

Attempted to render an undefined content collection entry.

See Docs Reference
Check if the entry is undefined before passing it to render()

errors/errors.js:16:5

…
    if (message) this.message = message;
    ^
…

Stack Trace

RenderUndefinedEntryError
    at new AstroError (/home/projects/kkvilwbjno.github/node_modules/astro/dist/core/errors/errors.js:16:5)
    at renderEntry (/home/projects/kkvilwbjno.github/node_modules/astro/dist/content/runtime.js:345:11)
    at eval (/home/projects/kkvilwbjno.github/node_modules/@astrojs/starlight/routes/common.astro:18:71)
    at AstroComponentInstance.common (/home/projects/kkvilwbjno.github/node_modules/astro/dist/runtime/server/astro-component.js:19:12)
    at AstroComponentInstance.init (/home/projects/kkvilwbjno.github/node_modules/astro/dist/runtime/server/render/astro/instance.js:38:29)
    at bufferHeadContent (file:///home/projects/kkvilwbjno.github/node_modules/astro/dist/runtime/server/render/astro/render.js:142:37)
    at Module.renderToAsyncIterable (file:///home/projects/kkvilwbjno.github/node_modules/astro/dist/runtime/server/render/astro/render.js:159:11)
    at async Module.renderPage (file:///home/projects/kkvilwbjno.github/node_modules/astro/dist/runtime/server/render/page.js:46:24)
    at async lastNext (file:///home/projects/kkvilwbjno.github/node_modules/astro/dist/core/render-context.js:179:25)
    at async eval (file:///home/projects/kkvilwbjno.github/node_modules/astro/dist/i18n/middleware.js:64:22)

and the following console output:

❯ npm install && npm run dev

added 417 packages in 11s

206 packages are looking for funding
  run `npm fund` for details

> @example/[email protected] dev
> astro dev

12:38:54 [types] Generated 4ms

 astro  v5.0.9 ready in 8118 ms

┃ Local    http://localhost:4321/
┃ Network  use --host to expose

The collection "docs" does not exist or is empty. Ensure a collection directory with this name exists.
12:39:00 [content] Syncing content
12:39:00 [content] Content config changed
12:39:00 [content] Astro version changed
12:39:00 [content] Clearing content store
12:39:00 [content] Synced content
12:39:00 watching for file changes...
12:39:04 [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/kkvilwbjno.github/node_modules/astro/dist/core/errors/errors.js:16:5
    [...] See full stack trace in the browser, or rerun with --verbose.

Link to Minimal Reproducible Example

https://stackblitz.com/github/withastro/starlight/tree/main/examples/basics

Participation

  • I am willing to submit a pull request for this issue.
@delucis
Copy link
Member

delucis commented Dec 18, 2024

Thanks for the issue @andersk. I’ve also been seeing this intermittently. It seems there are some race conditions in content collection loading that can lead to this.

A workaround is to type s and then enter in the dev server terminal to force refresh content, but obviously this is not a very pleasant dev experience.

I’m going to transfer this to the main Astro monorepo as it will need addressing there I believe.

@delucis delucis transferred this issue from withastro/starlight Dec 18, 2024
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Dec 18, 2024
@techfg
Copy link

techfg commented Dec 22, 2024

I've encountered this issue in several projects in Stackblitz and locally. In all cases, running npm install again and/or npm run astro sync seems to resolve the issue. However, in a project I just attempted to upgrade from 4 to 5, nothing seems to resolve the issue and I'm unable to get past it. I've tried sync, force, etc. and continue to encounter the The collection "docs" does not exist or is empty. Ensure a collection directory with this name exists. error along with RenderUndefinedEntryError.

Couple of additional notes:

  1. Astro 5.1.1 & Starlight 0.30.3
  2. The site is in a subdirectory from root (./site) which is different than the other projects I've encountered this issue with
  3. The site has a base which is different than other projects I've encountered this issue with
  4. using legacy: { collections: true } does not encounter the issue

Are there any other potential workarounds until this is addressed?

EDIT: Was finally able to get it to work, just kept deleting ./astro, ./node_modules, running sync, force over and over until it finally worked when running dev.

@ascorbic
Copy link
Contributor

Is this just occurring on Linux, or is anyone experiencing it on other platforms?

@ascorbic ascorbic added - P4: important Violate documented behavior or significantly impacts performance (priority) feat: content layer Related to the Content Layer feature (scope) and removed needs triage Issue needs to be triaged labels Dec 23, 2024
@ascorbic ascorbic self-assigned this Dec 23, 2024
@oluwatobiss
Copy link

I'm experiencing the same on Windows.

@techfg
Copy link

techfg commented Dec 23, 2024

Just tested that same site on windows. I got the The collection "docs" does not exist or is empty. Ensure a collection directory with this name exists. error but the site rendered and I didn't get the RenderUndefinedEntryError error.

Limited testing, obviously, but I think the underlying issue is not platform specific from best I can tell and @oluwatobiss confirmed as much I believe.

@ascorbic
Copy link
Contributor

If you'd like to try an experimental build that should fix it, install astro@experimental--dev-after-sync

@andersk
Copy link
Contributor Author

andersk commented Dec 23, 2024

Yeah the experimental--dev-after-sync build from #12818 seems to work in my project.

@techfg
Copy link

techfg commented Dec 24, 2024

Seems to be a race condition that causes this so difficult to say for certain if astro@experimental--dev-after-sync fully resolves the issue but I tried several attempts running from a "clean" state and haven't been able to reproduce the issue when using it. Looking good, thank you!

@Princesseuh
Copy link
Member

Fixing this will probably also fix #12456

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P4: important Violate documented behavior or significantly impacts performance (priority) feat: content layer Related to the Content Layer feature (scope)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants