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

astro dev slow or unresponsive when using content collections #6173

Closed
1 task
ChristineTham opened this issue Feb 8, 2023 · 7 comments · Fixed by #6257
Closed
1 task

astro dev slow or unresponsive when using content collections #6173

ChristineTham opened this issue Feb 8, 2023 · 7 comments · Fixed by #6257
Assignees
Labels
- P4: important Violate documented behavior or significantly impacts performance (priority)

Comments

@ChristineTham
Copy link

What version of astro are you using?

2.0.8

Are you using an SSR adapter? If so, which one?

None

What package manager are you using?

yarn

What operating system are you using?

Mac

Describe the Bug

Minimal example is a simple site with content collections.

astro check shows no errors

astro build and astro preview works

astro dev hangs - does not render a page.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/withastro-astro-qcexpn

Participation

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

Looking more closely at the code, I think the issue may be caused by the index page calling getCollection('doc') but the layout page for the content is also calling getCollection('doc')

@matthewp
Copy link
Contributor

matthewp commented Feb 8, 2023

is getCollection('doc') slow? Did you dig into why?

@matthewp matthewp added the needs response Issue needs response from OP label Feb 8, 2023
@ChristineTham
Copy link
Author

is getCollection('doc') slow? Did you dig into why?

I don't think it's slow, but not handling reentrant calls in dev. Basically, index.astro is calling await getCollection('doc'), but the collection itself has pages referencing a layout that also does await getCollection('doc') and this causes a hang. I'll try and create another, even smaller example that illustrates this.

@matthewp
Copy link
Contributor

matthewp commented Feb 8, 2023

Oh! I can see how we might run into this issue. cc @bholmesdev possible circular dep issue here. A smaller reproduction would be helpful, thanks!

@matthewp matthewp added - P4: important Violate documented behavior or significantly impacts performance (priority) and removed needs response Issue needs response from OP labels Feb 8, 2023
@ChristineTham
Copy link
Author

Oh! I can see how we might run into this issue. cc @bholmesdev possible circular dep issue here. A smaller reproduction would be helpful, thanks!

Here is an even smaller example, based on the Astro Basics starter. Basically the problem reared itself as soon as I added a getCollections in the Blog.layout file.

https://stackblitz.com/edit/github-3pq5xf

@JerryWu1234
Copy link
Contributor

mark

@bholmesdev
Copy link
Contributor

@matthewp This is interesting, because Vite handles circular dependencies with Astro.glob pretty well. My guess is our internal async imports aren't handled properly 🤔

In the meantime @ChristineTham, I'll suggest replacing your layout prop with an explicit layout wherever you're using these blog posts. This is the best practice we're trying to encourage anyways, and should remove the circular dependency issue!

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)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants