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

Missing content directory throws unhelpful error #741

Closed
1 task
TheOtterlord opened this issue Sep 22, 2023 · 3 comments · Fixed by #745
Closed
1 task

Missing content directory throws unhelpful error #741

TheOtterlord opened this issue Sep 22, 2023 · 3 comments · Fixed by #745
Assignees
Labels
🐛 bug Something isn't working

Comments

@TheOtterlord
Copy link
Member

What version of starlight are you using?

0.10.1

What version of astro are you using?

3.1.2

What package manager are you using?

npm

What operating system are you using?

Linux

What browser are you using?

Firefox

Describe the Bug

A missing content folder throws an obscure error. It's not an error I'd expect people to frequently encounter, but I this we can add a more useful error, just to cover this case.

11:48:31 [vite] Error when evaluating SSR module /node_modules/@astrojs/starlight/utils/routing.ts:
|- TypeError: (intermediate value).map is not a function
    at eval (/home/otterlord/Documents/Repos/api/test/node_modules/@astrojs/starlight/utils/routing.ts:10:66)
    at async instantiateModule (file:///home/otterlord/Documents/Repos/api/test/node_modules/vite/dist/node/chunks/dep-df561101.js:55974:9)

11:48:31 [vite] Error when evaluating SSR module /home/otterlord/Documents/Repos/api/test/node_modules/@astrojs/starlight/index.astro: failed to import "/node_modules/@astrojs/starlight/utils/routing.ts"
|- TypeError: (intermediate value).map is not a function
    at eval (/home/otterlord/Documents/Repos/api/test/node_modules/@astrojs/starlight/utils/routing.ts:10:66)
    at async instantiateModule (file:///home/otterlord/Documents/Repos/api/test/node_modules/vite/dist/node/chunks/dep-df561101.js:55974:9)

 error   (intermediate value).map is not a function
  File:
    /home/otterlord/Documents/Repos/api/test/node_modules/@astrojs/starlight/utils/routing.ts:38:66
  Code:
    37 | /** All entries in the docs content collection. */
    > 38 | const docs: StarlightDocsEntry[] = (await getCollection('docs')).map(({ slug, ...entry }) => ({
         |                                                                  ^
      39 |   ...entry,
      40 |   slug: normalizeIndexSlug(slug),
      41 | }));
  Stacktrace:
TypeError: (intermediate value).map is not a function
    at /home/otterlord/Documents/Repos/api/test/node_modules/@astrojs/starlight/utils/routing.ts:38:66
    at async instantiateModule (file:///home/otterlord/Documents/Repos/api/test/node_modules/vite/dist/node/chunks/dep-df561101.js:55974:9)

My proposal would be to check getCollection returns an array, then if not, throw an error about content not being found.

Link to Minimal Reproducible Example

No response

Participation

  • I am willing to submit a pull request for this issue.
@TheOtterlord TheOtterlord added the 🐛 bug Something isn't working label Sep 22, 2023
@TheOtterlord
Copy link
Member Author

Adding a note, but not closing yet until I confirm the cause. It looks like this is related to a behaviour change in Astro, post 3.0.6. I need to confirm if this is intentional. Tf it is, I'll continue working on my edge-case fix, if not, I'll close this and follow up with core

@TheOtterlord
Copy link
Member Author

Confirming this was an accepted behaviour change in 3.1.2 (withastro/astro#8336). I'll add something to address this in Starlight.

@TheOtterlord TheOtterlord self-assigned this Sep 22, 2023
@TheOtterlord
Copy link
Member Author

Another note. The behaviour introduced in 3.1.2 is not what is expected, so we'll have to wait for a patch release to finalise behaviour before I can fix this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant