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

[gatsby-source-wordpress] prevent duplicate nodes for remote media files #3842

Closed

Conversation

Fetten
Copy link
Contributor

@Fetten Fetten commented Feb 3, 2018

This fixes #3562

@gatsbybot
Copy link
Collaborator

Deploy preview for gatsbygram ready!

Built with commit dae5664

https://deploy-preview-3842--gatsbygram.netlify.com

@KyleAMathews KyleAMathews requested a review from pieh February 3, 2018 18:43
@pieh
Copy link
Contributor

pieh commented Feb 3, 2018

Shouldn't we fix that in gatsby-source-filesystem ? To not replicate it in every source plugin?

We can check there if node for that remote file is already created and return that node? Am I missing something?

@Fetten
Copy link
Contributor Author

Fetten commented Feb 3, 2018

Yes, I first thought of caching the url in gatsby-source-filesystem's create-remote-file-node.js, but then I realized, that multiple requests can run in parallel. This makes it hard to check for a cached local-file node before a duplicate request, as the first one might not be finished yet.

It would be great if anybody had an idea how to solve this.

@pieh
Copy link
Contributor

pieh commented Feb 3, 2018

we can store promises - like that pieh@af21319 (would just need better comments)

@Fetten
Copy link
Contributor Author

Fetten commented Feb 3, 2018

Wow, never thought of caching a whole promise :) But if this works, let's go for it.
I'll close this PR if you would like to send one for your version.

@pieh
Copy link
Contributor

pieh commented Feb 3, 2018

We can keep that PR open for now. My code does work and fix fetching problem, but not sure yet if we won't have similar problem when we try to process those images (using transformer-sharp for example) and will check it tomorrow.

@KyleAMathews
Copy link
Contributor

We cache promises like @pieh's PR elsewhere in core and it works great so let's go with his more general solution.

Thanks @Fetten for the PR all the same!

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

Successfully merging this pull request may close these issues.

[gatsby-source-wordpress] After adding wordpress plugin, gatsby develop throws error
4 participants