-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Error when using a Reference and an inline Loader #12087
Comments
I was going to experiment with the new content layer because I really need this feature, but i saw this issue, and since it seems to be an use case I need, I tried to investigate. The issue appears to be the same in either dev or build, and both in Astro v4.15.9 and the last beta. astro/packages/astro/src/content/runtime.ts Line 590 in 2594eb0
to find the referenced collection, but the store is loaded completely empty
because the data store is not written to disk until all the collection have finished loading, and before that every collection tries to validate the schema.
I can see that the mutable data store tries so hard to save the file to disk
but it's file path reference is empty until writeToDisk is called at the end of collection loading.
I may be missing something but I think that every collection "existence" should be initialized before trying to validate schemas, otherwise references will never work. |
I had the same problem with inline loader with Astro beta 5. I show an example of my use case:
When I run npm run build I get
|
@mollimoll thanks for the report. I'm investigating this now. @carlosmonterocanabal your issue is different: you shouldn't be trying to use @StevenDepa Are you also trying to getCollection inside a loader? Can you share your code? The runtime is not supposed to be used before the loaders have run. |
@mollimoll ok, I'm reproduced it and can see where the issue is. It's a race condition. I'll get a fix out. Thanks again for the report and great repro! |
Astro Info
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
I'm using an inline loader, combined with a schema
reference
to another collection. When I runnpm run build
I receive an error stating the "Collection does not exist or is empty."I can reproduce this issue on StackBlitz with the experimental contentLayer flag, but it is also occurring in the Astro 5 beta.
What's the expected result?
I'd expect the build to pass, and that Astro does not fail if a collection is empty (if that is indeed the issue).
Link to Minimal Reproducible Example
https://stackblitz.com/edit/withastro-astro-mn5gwx?file=src%2Fcontent%2Fconfig.ts
Participation
The text was updated successfully, but these errors were encountered: