question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Gatsby-source-wordpress fetches random amount but rarely all acf_media

See original GitHub issue

Description

I am trying to build a gatsby site with wordpress using acf fields and gatsby-source-wordpress. Unfortunately since adding a a few posts I run into the issue that not all but different images are being fetched every time. The problem is hard to track as I don’t get any error messages and it appears to be random.

The result is usually even worse when deploying to netlify. The project I am working on currently has only 13 posts and 109 wordpress__acf_media to fetch in total.

I looked into similar issues but non of the solutions worked for me. The same issues occurred in previous node versions and before updating all the modules. work on two other websites where I use wordpress-source-plugin as well and the result is very similar.

-> wordpress__acf_options fetched : 1 -> wordpress__acf_posts fetched : 13 -> wordpress__acf_pages fetched : 1 -> wordpress__acf_media fetched : 93 -> wordpress__acf_blocks fetched : 0 -> wordpress__acf_categories fetched : 5 -> wordpress__acf_tags fetched : 0 -> wordpress__POST fetched : 13 -> wordpress__PAGE fetched : 1 -> wordpress__wp_media fetched : 109 -> wordpress__wp_taxonomies fetched : 1 -> wordpress__CATEGORY fetched : 5

The result looks different every time: success Downloading remote files - 6.985s - 10/109 15.60/s success Downloading remote files - 45.059s - 58/109 2.42/s success Downloading remote files - 18.224s - 39/109 5.98/s

Steps to reproduce

Possible conflict with a wordpress plugin? Although I tried to deactivate and delete the ones that are not related to acf and the result didn’t change.

Wordpress Plugins used:

• ACF to REST Api • Advanced Custom Fields PRO • Category Order and Taxonomy Terms Order • TinyMCE Advanced • Webhook Netlify Deploy • WP REST API CacheDeactivate

gatsby-config.js

{
      resolve: `gatsby-source-wordpress`,
      options: {
        baseUrl: `arc.im-burrow.com`,
        protocol: `https`,
        hostingWPCOM: false,
        useACF: true,
        verboseOutput: false,
        includedRoutes: [
          "**/categories",
          "**/posts",
          "**/pages",
          "**/media",
          "**/tags",
          "**/taxonomies",
        ],
        excludedRoutes: [
          "**/comments",
          "**/users",
        ],
        keepMediaSizes: false,
        concurrentRequests: 10,
      }
    },

I assume it is not a graphql issue, never the less:

query {
    allWordpressPost {
      edges {
        node {
          title
          path
          categories{
            slug
          }
          acf {
            index {
              localFile {
                childImageSharp {
                  fluid(maxWidth: 700){
                    ...GatsbyImageSharpFluid_withWebp
                  }
                }
              }
            }
          }
        }
      }
    }
    allWordpressCategory {
      edges {
        node {
          slug
        }
      }
    }
    
  }

Expected result

All images should be downloaded and image.localFile should be accessible.

Actual result

Random amount of media is not being downloaded and return “null”.

Environment

System: OS: macOS 10.15.2 CPU: (4) x64 Intel® Core™ i5-5257U CPU @ 2.70GHz Shell: 3.2.57 - /bin/bash Binaries: Node: 12.13.0 - /usr/local/bin/node Yarn: 1.10.1 - /usr/local/bin/yarn npm: 6.12.0 - /usr/local/bin/npm Languages: Python: 2.7.16 - /usr/bin/python Browsers: Chrome: 78.0.3904.108 Safari: 13.0.4 npmPackages: gatsby: ^2.18.10 => 2.18.10 gatsby-image: ^2.2.34 => 2.2.34 gatsby-plugin-manifest: ^2.2.31 => 2.2.31 gatsby-plugin-offline: ^3.0.27 => 3.0.27 gatsby-plugin-react-helmet: ^3.1.16 => 3.1.16 gatsby-plugin-sass: ^2.1.24 => 2.1.24 gatsby-plugin-sharp: ^2.3.5 => 2.3.5 gatsby-source-filesystem: ^2.1.40 => 2.1.40 gatsby-source-wordpress: ^3.1.51 => 3.1.51 gatsby-transformer-sharp: ^2.3.7 => 2.3.7 npmGlobalPackages: gatsby-cli: 2.8.16

Any Ideas?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
TylerBarnescommented, Dec 12, 2019

@BURROO if that fixed your problem it’s an issue with the amount of concurrent requests overloading your server. Local servers can also suffer from this problem, although you could likely tweak your local server until it can handle that many concurrent connections. For ex I’m using Local by flywheel locally and it’s actually far slower and can handle less concurrent connections than the pantheon site I’m using for testing.

I’m currently building out the next version of gatsby-source-wordpress which is a ground-up rewrite. I will be adding a retry with exponential backoff algorithm for fetching images and data, so this shouldn’t happen anymore in the next major version.

1reaction
BURROOcommented, Dec 16, 2019

@TylerBarnes thank you for the clarification.

@jromme It took me some time to figure this out as well. I added this snippet to the package.json inside “scripts”:

"build": "GATSBY_CONCURRENT_DOWNLOAD=5 gatsby build",
"develop": "GATSBY_CONCURRENT_DOWNLOAD=5 gatsby develop",

And then instead of gatsby develop or gatsby build, I was running npm run develop or npm run build.

If you also work with netlify for the remote build you can set an environment variable in the settings on your netlify panel.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Media fetch issue using gatsby-source-wordpress plugin ...
I am using gatsby-source-wordpress to fetch data and during gatsby build or gatsby develop I have media fetch issue RequestError: Timeout ...
Read more >
gatsby-source-wordpress
gatsby -source-wordpress Source plugin for pulling data into Gatsby from ... All entities are supported (posts, pages, tags, categories, media, types, users, ...
Read more >
Blog - WPGraphQL
GraphQL is most popularly known as a way to fetch data from remote sources via HTTP requests, but with WPGraphQL, you can access...
Read more >
How To Build A Blog with Wordpress and Gatsby.js – Part 2
It comes with a few plugins, but not too much so it's wide open for ... terminal npm install gatsby-source-wordpress gatsby-plugin-sitemap.
Read more >
Using New Gatsby Source WordPress Plugin - CSS-Tricks
js template files. When we view the GraphiQL API explorer at http://localhost:8000/___graphql we can see all of the data from WordPress exposed ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found