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-contentful] downloadLocal not working #18483

Closed
ascabknight opened this issue Oct 11, 2019 · 4 comments
Closed

[gatsby-source-contentful] downloadLocal not working #18483

ascabknight opened this issue Oct 11, 2019 · 4 comments
Labels
stale? Issue that may be closed soon due to the original author not responding any more.

Comments

@ascabknight
Copy link

ascabknight commented Oct 11, 2019

Description

In our company, we have built a web site using Gatsby and Contentful. Our CI has been experiencing perfromance issues with the build time. Running a build in Production is taking around 1.5 - 2 hours to complete (yes, it's a large website). Debugging the build process, I noticed that the Contentful assets were being downloaded despite the downloadLocal option was being set as "false".

Taking a look at the gatsby-source-contentful source code, I noticed that the downloadLocal option is not being validated correctly, the get method from the publishConfig object is returning a string value thus the following condition will always be true. This is even ignoring the default value of the downloadLocal option.

gatsby-node.js (Line 225)

//This will always be true since a string is being returned not a boolean.
if (pluginConfig.get('downloadLocal')) {
    await downloadContentfulAssets({
      actions,
      createNodeId,
      store,
      cache,
      getNodes,
      reporter,
    })
}

Steps to reproduce

  1. Setup the gatsby-source-contentful and gatsby-source-filesystem folder plugins in your website.
  2. Set the downloadLocal option as false.
  3. Run a gatsby build
  4. Take a look at the .cache folder and you will notice that assets are being downloaded into the gatsby-source-filesystem folder.
  5. Open the gatsby-node.js file from the gatsby-source-contentful plugin and run the following test. You will notice the results immediately:

Test

const downloadLocal = pluginConfig.get(`downloadLocal`)

//This will return true or false depending on your settings or the default value
console.error(`****** gatsby-source-contentful/downloadLocal: ${downloadLocal}. ******`)

//This returns: string.
console.log(`typeof: ${typeof downloadLocal }`)

// Double checking the downloadLocal flag, you can improve this implementation but for testing it works.
  if (downloadLocal && downloadLocal === true) {
    await downloadContentfulAssets({
      actions,
      createNodeId,
      store,
      cache,
      getNodes,
      reporter
    });
  }

Expected result

  • Setting downloadLocal as true should download assets locally.
  • Setting downloadLocal as false should NOT download assets locally.

Actual result

Setting downloadLocal as false is still downloading contentful assets in the local folder impacting our build times.

Environment

Run gatsby info --clipboard in your project directory and paste the output here.

  System:
    OS: macOS 10.14.5
    CPU: (12) x64 Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
    Shell: 5.3 - /bin/zsh
  Binaries:
    Node: 10.16.3 - ~/.nvm/versions/node/v10.16.3/bin/node
    Yarn: 1.17.3 - /usr/local/bin/yarn
    npm: 6.9.0 - ~/.nvm/versions/node/v10.16.3/bin/npm
  Languages:
    Python: 2.7.10 - /usr/bin/python
  Browsers:
    Chrome: 77.0.3865.90
    Firefox: 68.0
    Safari: 12.1.1
  npmPackages:
    gatsby: ^2.15.30 => 2.15.35 
    gatsby-image: ^2.2.7 => 2.2.7 
    gatsby-plugin-eslint: ^2.0.4 => 2.0.5 
    gatsby-plugin-google-tagmanager: ^2.1.3 => 2.1.4 
    gatsby-plugin-i18next: ^1.1.7 => 1.1.7 
    gatsby-plugin-react-helmet: ^3.1.1 => 3.1.2 
    gatsby-plugin-react-svg: ^2.1.1 => 2.1.1 
    gatsby-plugin-resolve-src: ^2.0.0 => 2.0.0 
    gatsby-plugin-robots-txt: ^1.5.0 => 1.5.0 
    gatsby-plugin-sharp: ^2.2.5 => 2.2.9 
    gatsby-plugin-styled-components: ^3.1.1 => 3.1.2 
    gatsby-source-contentful: ^2.1.11 => 2.1.15 
    gatsby-source-filesystem: ^2.1.4 => 2.1.6 
    gatsby-transformer-remark: ^2.6.3 => 2.6.9 
    gatsby-transformer-sharp: ^2.2.2 => 2.2.4 

@gatsbot
Copy link

gatsbot bot commented Nov 1, 2019

Hiya!

This issue has gone quiet. Spooky quiet. 👻

We get a lot of issues, so we currently close issues after 30 days of inactivity. It’s been at least 20 days since the last update here.

If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open!

As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks for being a part of the Gatsby community! 💪💜

@gatsbot gatsbot bot added the stale? Issue that may be closed soon due to the original author not responding any more. label Nov 1, 2019
@samuelgoldenbaum
Copy link

To add: I get the following logged when setting downloadLocal: true and running gatsby build

 ERROR 

(node:60875) [DEP0066] DeprecationWarning: OutgoingMessage.prototype._headers is deprecated

@gatsbot
Copy link

gatsbot bot commented Nov 13, 2019

Hey again!

It’s been 30 days since anything happened on this issue, so our friendly neighborhood robot (that’s me!) is going to close it.

Please keep in mind that I’m only a robot, so if I’ve closed this issue in error, I’m HUMAN_EMOTION_SORRY. Please feel free to reopen this issue or create a new one if you need anything else.

As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks again for being part of the Gatsby community!

@gatsbot gatsbot bot closed this as completed Nov 13, 2019
@AnalogMemory
Copy link
Contributor

AnalogMemory commented Nov 18, 2019

I ran into this issue today with node 12.13.0, temporarily solved by downgrading to node 10.17.0

It's an issue with a dependency in gatsby-source-filesystem see #18857
Looks like it'll be fixed in a few months

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale? Issue that may be closed soon due to the original author not responding any more.
Projects
None yet
Development

No branches or pull requests

3 participants