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

Markdown nodes null in production #232

Open
sbuys opened this issue Feb 5, 2022 · 8 comments
Open

Markdown nodes null in production #232

sbuys opened this issue Feb 5, 2022 · 8 comments

Comments

@sbuys
Copy link

sbuys commented Feb 5, 2022

Using 2.8.0

Picking up from #214, where the same issue occurred with local images - null in production but valid in development. Not sure if the issue here is related.

Example project with public API endpoint.

Plugin config:

{
  resolve: 'gatsby-source-graphcms',
    options: {
      endpoint: process.env.GRAPHCMS_API_ENDPOINT,
      buildMarkdownNodes: true,
      downloadLocalImages: true,
    },
}
`
@DennisSimon
Copy link

Hey everyone,

I have the same issue with buildMarkdownNodes working in development but not in production mode.
Are there any logs that we can provide to assist in debugging?

@sbuys
Copy link
Author

sbuys commented Feb 13, 2022

@notrab anything we can do to help on this one? We are stuck in a holding pattern on a few projects.

@DennisSimon
Copy link

So i managed to work around the issue in my case, which is very similar to the case that you posted as an example @sbuys.
Here is a quick rundown of what i changed:

Previously, i was simply querying the ids of all posts/pages that contained the markdownNodes in gatsby-node.js, passed them to the gatsby template pages via the context and then retrieved all required fields within the template via page queries.

I found that when i query all required fields within gatsby-node and then pass all of them via the context, the markdownNodes are not null anymore.

I am guessing that this might be either due to some sort of race-condition (might explain why it works during development as the fields are queried on demand) or an issue where certain nodes are simply not available during page queries.

@DennisSimon
Copy link

Another piece of information:

I noticed that the workaround i posted above suddenly stopped working.
To get it working again, i needed to clean the cache and rebuild.

So it might also be a caching issue?

@sbuys
Copy link
Author

sbuys commented Feb 17, 2022

@DennisSimon thanks for the update. I'll look into the caching and report back.

@sbuys
Copy link
Author

sbuys commented Feb 28, 2022

@DennisSimon The problem actually seems tied to the code in onCreateNode().

Per the documentation for Gatsby v4, mutation of nodes outside of createNode() is an anti-pattern. More info here.

field.value.markdownNode = markdownNode.id will not update the node in the Gatsby store and the fact that it works in development is probably a fluke.

What I'm not sure about is how to use the recommended API createNodeField as it seems you can't alter a field directly.

@zzullick
Copy link

Any updates or workaround on this issue? Experiencing the same thing with 2.8.0 and gatsby 4.20.0.

@sbuys
Copy link
Author

sbuys commented Aug 10, 2022

@zzullick we moved to another CMS. We're one of the case studies on the website too 💔.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants