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

The plugin "gatsby-source-name" created a node of a type "File" owned by "gatsby-source-filesystem" #38117

Closed
tordans opened this issue May 26, 2023 · 16 comments · Fixed by #38235
Labels
status: confirmed Issue with steps to reproduce the bug that’s been verified by at least one reviewer. topic: source-plugins Relates to the Gatsby source plugins (e.g. -filesystem) type: bug An issue or pull request relating to a bug in Gatsby

Comments

@tordans
Copy link
Contributor

tordans commented May 26, 2023

Description

This is extracted from https://github.com/gatsby-uc/plugins/issues/426#issuecomment-1562455390…

LekoArts commented on 2023-05-25

This shouldn't happen and is probably a regression from #37782
The current PR gatsby-uc/plugins#431 shouldn't be merged as this needs to be fixed inside gatsby

… and gatsby-uc/plugins#426 (comment)

LekoArts commented on 2023-05-25

File nodes should be managed by gatsby-source-filesystem and that's how it used to work in the past.

However, https://github.com/gatsby-uc/plugins/pull/431/files#diff-77a5459c74cf8818897d5690b621b8bca7f96d363a1eb68a6ed55f65711e061aR61 seems like a correct change. The source plugin shouldn't touch File nodes, it should only touch its own nodes: https://www.gatsbyjs.com/docs/tutorial/creating-a-source-plugin/part-5/#1-prevent-garbage-collection

The linked issues goes into more details.

Reproduction Link

Steps to Reproduce

Expected Result

Actual Result

Environment

-

Config Flags

No response

@tordans tordans added the type: bug An issue or pull request relating to a bug in Gatsby label May 26, 2023
@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label May 26, 2023
@LekoArts LekoArts added status: needs reproduction This issue needs a simplified reproduction of the bug for further troubleshooting. topic: source-plugins Relates to the Gatsby source plugins (e.g. -filesystem) and removed status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer labels May 30, 2023
@LekoArts
Copy link
Contributor

Can you please attach a minimal reproduction we can run?
I don't have a Strapi account or it hosted somewhere and we'd need that to run the source plugin.

@laurenskling
Copy link
Contributor

@derrickmehaffy is there a Strapi demo site the Gatsby team can use to debug this issue?

@tordans
Copy link
Contributor Author

tordans commented May 30, 2023

Can you please attach a minimal reproduction we can run? I don't have a Strapi account or it hosted somewhere and we'd need that to run the source plugin.

@LekoArts you can fork https://github.com/FixMyBerlin/plan-f.info and use it with our staging content to test the integration.
Please send me an email to tobias@fixmycity.de for the required .env variable to pull data from the Strapi backend (which we have at https://github.com/FixMyBerlin/plan-f-backend).

~~Update: Sorry, just realized the repos are still private, will make them public today…~~~
Update: The repos are now public

@derrickmehaffy
Copy link

@derrickmehaffy is there a Strapi demo site the Gatsby team can use to debug this issue?

Public hosted? Not that I'm aware of, easiest might be using foodadvisor?

@rileybathurst
Copy link

I built this here
https://github.com/rileybathurst/strapi-bug
with the strapi key in the gastby-config file and the server at
http://45.79.101.19:1345/
let me know if you need any changes on this

@LekoArts LekoArts added status: confirmed Issue with steps to reproduce the bug that’s been verified by at least one reviewer. and removed status: needs reproduction This issue needs a simplified reproduction of the bug for further troubleshooting. labels Jun 1, 2023
@LiamJSP
Copy link

LiamJSP commented Jun 13, 2023

I'd like to add that this issue is affecting most gatsby-source plugins using File/localFile. It also affects gatsby-source-prismic, and gatsby-source-directus. Is this related to recent tweaks to node ownership I see mentioned in some version changelogs?

prismicio/prismic-gatsby#530

@LekoArts LekoArts changed the title bug(gatsby-source-strapi): The plugin "gatsby-source-strapi" created a node of a type "File" owned by "gatsby-source-filesystem" The plugin "gatsby-source-name" created a node of a type "File" owned by "gatsby-source-filesystem" Jun 14, 2023
@LekoArts
Copy link
Contributor

Thanks for that context @LiamJSP - we've been busy with something else but given that this seems to be more widespread I'll escalate this

@JustinGillespie
Copy link

This issue is breaking our builds as well. From what i've read, downgrading to 5.8.0 will solve the issue, but i've had no luck so far. Hopefully this can be fixed soon.

@TylerBarnes
Copy link
Contributor

TylerBarnes commented Jun 14, 2023

I believe I've fixed it, can someone try this canary? gatsby@5.11.0-touch-nodes-fix.4 I tried it on @rileybathurst 's repro above and it seemed to work.

I think the oversight here was thinking nodes shouldn't be touched by a plugin that doesn't own them. I'm not sure source-strapi should touch File nodes but I believe allowing it to again will make this work

EDIT: btw for trying the canary with the mentioned repro I had to use yarn due to dep tree issues, npm wouldn't install the canary. In a released version that wont be an issue, it's just for the canary

@laurenskling
Copy link
Contributor

Thanks for the help @TylerBarnes and @pieh . Anything we can do to improve on our side?

@LekoArts
Copy link
Contributor

Our, as-in source plugins?

Yeah, we saw room of improvement here:

  • Ideally the source plugin creates Asset types for nodes that will hold those image assets
  • When calling createRemoteFileNode the parentNodeId should be set to those Asset
  • You don't touchNode File nodes but only your Asset nodes. Because they are linked, files will be kept around

This is what gatsby-source-contentful is doing

@LekoArts
Copy link
Contributor

LekoArts commented Jun 15, 2023

The fix to this issue was released in gatsby@5.11.0. Please try that 👍

@LiamJSP
Copy link

LiamJSP commented Jun 15, 2023

I can confirm gatsby-source-prismic is now working with gatsby@5.11.0! I got a working build. Thanks a bunch all! I'll CC LekoArts suggestions for source-plugin improvement into the respective Prismic thread. Thx again!

@TylerBarnes
Copy link
Contributor

In addition to creating Asset nodes as @LekoArts mentioned you can avoid touching nodes entirely by using the new enableStatefulSourceNodes action: https://www.gatsbyjs.com/docs/reference/config-files/actions/#enableStatefulSourceNodes. For very large sites this has a pretty substantial perf improvement as well

@rileybathurst
Copy link

I believe I've fixed it, can someone try this canary? gatsby@5.11.0-touch-nodes-fix.4 I tried it on @rileybathurst 's repro above and it seemed to work.

I think the oversight here was thinking nodes shouldn't be touched by a plugin that doesn't own them. I'm not sure source-strapi should touch File nodes but I believe allowing it to again will make this work

EDIT: btw for trying the canary with the mentioned repro I had to use yarn due to dep tree issues, npm wouldn't install the canary. In a released version that wont be an issue, it's just for the canary

Thanks for the fix.
Are you cool with me pulling the same project down or would you like it left up for more testing?

@TylerBarnes
Copy link
Contributor

Feel free to take it down, thanks for the repro!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: confirmed Issue with steps to reproduce the bug that’s been verified by at least one reviewer. topic: source-plugins Relates to the Gatsby source plugins (e.g. -filesystem) type: bug An issue or pull request relating to a bug in Gatsby
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants