jlengstorf / netlify-plugin-gatsby-cache

185 stars 21 forks source link

Build failures #26

Closed guybowden closed 4 years ago

guybowden commented 4 years ago

I'm not sure if this is a Gatsby issue, a netlify build issue, or this plugin, but I'm now seeing errors like this on cache enabled builds:

I have tried it without this plugin and it works fine. I've also tried it without netlify builds beta enabled and it works fine.

Local builds with and without .cache also work fine.

9:47:40 AM: failed Building production JavaScript and CSS bundles - 66.915s
9:47:40 AM: 
9:47:40 AM: error Generating JavaScript bundles failed
9:47:40 AM: Can't resolve '../../../public/static/d/210650851.json' in '/opt/build/repo/src/components/ProductPage'
9:47:40 AM: 
9:47:40 AM: 
9:47:40 AM: error Generating JavaScript bundles failed
9:47:40 AM: Can't resolve '../../public/static/d/2417117884.json' in '/opt/build/repo/src/components'
9:47:40 AM: 
9:47:40 AM: error Generating JavaScript bundles failed
9:47:40 AM: Can't resolve '../../public/static/d/2804179359.json' in '/opt/build/repo/src/components'
9:47:40 AM: 
9:47:40 AM: error Generating JavaScript bundles failed
9:47:40 AM: Can't resolve '../../public/static/d/905240021.json' in '/opt/build/repo/src/components'

Relevant gatsby deps:

    "gatsby": "^2.21.7",
    "gatsby-image": "^2.4.0",
    "gatsby-plugin-canonical-urls": "^2.3.0",
    "gatsby-plugin-manifest": "^2.4.1",
    "gatsby-plugin-material-ui": "^2.1.8",
    "gatsby-plugin-offline": "^2.2.0",
    "gatsby-plugin-react-helmet": "^3.3.0",
    "gatsby-plugin-remove-fingerprints": "^0.0.2",
    "gatsby-plugin-sharp": "^2.6.0",
    "gatsby-plugin-webpack-bundle-analyzer": "^1.0.5",
    "gatsby-source-contentful": "^2.3.1",
    "gatsby-source-elasticsearch": "^0.1.0",
    "gatsby-source-filesystem": "^2.3.0",
    "gatsby-transformer-remark": "^2.8.3",
    "gatsby-transformer-sharp": "^2.5.0",

Full build log below

9:45:22 AM: Build ready to start
9:45:24 AM: build-image version: 2dbd444fcdce00cf06325060a8238d5ae3e86774
9:45:24 AM: build-image tag: v3.3.7
9:45:24 AM: buildbot version: d305548225ac57bb00eb5a596b0b8674e76a4681
9:45:24 AM: Fetching cached dependencies
9:45:24 AM: Starting to download cache of 350.7MB
9:45:33 AM: Finished downloading cache in 8.465062079s
9:45:33 AM: Starting to extract cache
9:45:57 AM: Finished extracting cache in 24.094433922s
9:45:57 AM: Finished fetching cache in 32.69641939s
9:45:57 AM: Starting to prepare the repo for build
9:45:58 AM: Preparing Git Reference refs/heads/prod
9:45:59 AM: Different publish path detected, going to use the one specified in the Netlify configuration file: 'build' versus 'public' in the Netlify UI
9:45:59 AM: Different functions path detected, going to use the one specified in the Netlify configuration file: 'functions/dist' versus '' in the Netlify UI
9:45:59 AM: Different build command detected, going to use the one specified in the Netlify configuration file: 'npm run build' versus 'yarn build' in the Netlify UI
9:45:59 AM: Creating functions prep folder
9:45:59 AM: Starting build script
9:45:59 AM: Installing dependencies
9:46:00 AM: Started restoring cached node version
9:46:05 AM: Finished restoring cached node version
9:46:05 AM: Attempting node version '10.16.0 ' from .nvmrc
9:46:06 AM: v10.16.0 is already installed.
9:46:06 AM: Now using node v10.16.0 (npm v6.9.0)
9:46:06 AM: Attempting ruby version 2.6.2, read from environment
9:46:08 AM: Using ruby version 2.6.2
9:46:08 AM: Using PHP version 5.6
9:46:08 AM: Started restoring cached node modules
9:46:08 AM: Finished restoring cached node modules
9:46:08 AM: Started restoring cached go cache
9:46:08 AM: Finished restoring cached go cache
9:46:08 AM: unset GOOS;
9:46:08 AM: unset GOARCH;
9:46:08 AM: export GOROOT='/opt/buildhome/.gimme/versions/go1.12.linux.amd64';
9:46:08 AM: export PATH="/opt/buildhome/.gimme/versions/go1.12.linux.amd64/bin:${PATH}";
9:46:08 AM: go version >&2;
9:46:08 AM: export GIMME_ENV='/opt/buildhome/.gimme/env/go1.12.linux.amd64.env';
9:46:09 AM: go version go1.12 linux/amd64
9:46:09 AM: Installing missing commands
9:46:09 AM: Verify run directory
9:46:10 AM: ​
9:46:10 AM: ┌─────────────────────────────┐
9:46:10 AM: │        Netlify Build        │
9:46:10 AM: └─────────────────────────────┘
9:46:10 AM: ​
9:46:10 AM: ❯ Version
9:46:10 AM:   @netlify/build 0.4.11
9:46:10 AM: ​
9:46:10 AM: ❯ Flags
9:46:10 AM:   mode: buildbot
9:46:10 AM: ​
9:46:10 AM: ❯ Current directory
9:46:10 AM:   /opt/build/repo
9:46:10 AM: ​
9:46:10 AM: ❯ Config file
9:46:10 AM:   /opt/build/repo/netlify.toml
9:46:10 AM: ​
9:46:10 AM: ❯ Context
9:46:10 AM:   production
9:46:12 AM: ​
9:46:12 AM: ❯ Loading plugins
9:46:12 AM:    - netlify-plugin-gatsby-cache@0.2.1
9:46:12 AM: ​
9:46:12 AM: ┌───────────────────────────────────────────────────────────┐
9:46:12 AM: │ 1. onPreBuild command from @netlify/plugin-functions-core │
9:46:12 AM: └───────────────────────────────────────────────────────────┘
9:46:12 AM: ​
9:46:12 AM: ​
9:46:12 AM: (@netlify/plugin-functions-core onPreBuild completed in 6ms)
9:46:12 AM: ​
9:46:12 AM: ┌────────────────────────────────────────────────────────┐
9:46:12 AM: │ 2. onPreBuild command from netlify-plugin-gatsby-cache │
9:46:12 AM: └────────────────────────────────────────────────────────┘
9:46:12 AM: ​
9:46:18 AM: Found a Gatsby cache. We’re about to go FAST. ⚡️
9:46:18 AM: ​
9:46:18 AM: (netlify-plugin-gatsby-cache onPreBuild completed in 5.4s)
9:46:18 AM: ​
9:46:18 AM: ┌────────────────────────────────────┐
9:46:18 AM: │ 3. build.command from netlify.toml │
9:46:18 AM: └────────────────────────────────────┘
9:46:18 AM: ​
9:46:18 AM: $ npm run build
9:46:18 AM: > gatsby-starter-default@0.1.0 build /opt/build/repo
9:46:18 AM: > gatsby build --prefix-paths && netlify-lambda build functions/src
9:46:22 AM: 
9:46:22 AM: success open and validate gatsby-configs - 0.180s
9:46:24 AM: 
9:46:24 AM: success load plugins - 2.343s
9:46:24 AM: 
9:46:24 AM: success onPreInit - 0.015s
9:46:24 AM: 
9:46:24 AM: success delete html and css files from previous builds - 0.018s
9:46:24 AM: 
9:46:24 AM: success initialize cache - 0.008s
9:46:24 AM: 
9:46:24 AM: success copy gatsby files - 0.056s
9:46:24 AM: 
9:46:24 AM: success onPreBootstrap - 0.010s
9:46:24 AM: 
9:46:24 AM: success createSchemaCustomization - 0.014s
9:46:26 AM: 
9:46:26 AM: Successfully processed 571 modelresult documents
9:46:26 AM: 
9:46:26 AM: Starting to fetch data from Contentful
9:46:26 AM: 
9:46:26 AM: info Fetching default locale
9:46:26 AM: info default locale is: en-US
9:46:26 AM: info contentTypes fetched 24
9:46:26 AM: 
9:46:26 AM: 
9:46:26 AM: info Updated entries 47
9:46:26 AM: 
9:46:26 AM: 
9:46:26 AM: info Deleted entries 0
9:46:26 AM: 
9:46:26 AM: 
9:46:26 AM: info Updated assets 26
9:46:26 AM: 
9:46:26 AM: 
9:46:26 AM: info Deleted assets 0
9:46:26 AM: 
9:46:26 AM: 
9:46:26 AM: Fetch Contentful data: 896.994ms
9:46:26 AM: 
9:46:26 AM: Restricted field found for ContentType Product and field id. Prefixing with contentful.
9:46:27 AM: 
9:46:27 AM: success source and transform nodes - 2.763s
9:46:30 AM: 
9:46:30 AM: success building schema - 2.713s
9:46:32 AM: 
9:46:32 AM: success createPages - 2.236s
9:46:32 AM: success createPagesStatefully - 0.078s
9:46:32 AM: success onPreExtractQueries - 0.001s
9:46:32 AM: success update schema - 0.244s
9:46:33 AM: success extract queries from components - 0.679s
9:46:33 AM: success write out requires - 0.016s
9:46:33 AM: 
9:46:33 AM: success write out redirect data - 0.001s
9:46:33 AM: success onPostBootstrap - 0.000s
9:46:33 AM: ⠀
9:46:33 AM: 
9:46:33 AM: info bootstrap finished - 14.654 s
9:46:33 AM: 
9:46:33 AM: ⠀
9:47:30 AM: 
9:47:30 AM: warning Browserslist: caniuse-lite is outdated. Please run next command `npm update`
9:47:40 AM: failed Building production JavaScript and CSS bundles - 66.915s
9:47:40 AM: 
9:47:40 AM: error Generating JavaScript bundles failed
9:47:40 AM: Can't resolve '../../../public/static/d/210650851.json' in '/opt/build/repo/src/components/ProductPage'
9:47:40 AM: 
9:47:40 AM: 
9:47:40 AM: error Generating JavaScript bundles failed
9:47:40 AM: Can't resolve '../../public/static/d/2417117884.json' in '/opt/build/repo/src/components'
9:47:40 AM: 
9:47:40 AM: error Generating JavaScript bundles failed
9:47:40 AM: Can't resolve '../../public/static/d/2804179359.json' in '/opt/build/repo/src/components'
9:47:40 AM: 
9:47:40 AM: error Generating JavaScript bundles failed
9:47:40 AM: Can't resolve '../../public/static/d/905240021.json' in '/opt/build/repo/src/components'
9:47:40 AM: not finished run queries - 67.064s
9:47:40 AM: npm ERR! code ELIFECYCLE
9:47:40 AM: npm
9:47:40 AM: ERR! errno 1
9:47:40 AM: npm
9:47:40 AM: ERR! gatsby-starter-default@0.1.0 build: `gatsby build --prefix-paths && netlify-lambda build functions/src`
9:47:40 AM: npm
9:47:40 AM: ERR! Exit status 1
9:47:40 AM: npm
9:47:40 AM:  ERR!
9:47:40 AM: npm ERR!
9:47:40 AM:  Failed at the gatsby-starter-default@0.1.0 build script.
9:47:40 AM: npm ERR!
9:47:40 AM:  This is probably not a problem with npm. There is likely additional logging output above.
9:47:40 AM: npm
9:47:40 AM:  ERR! A complete log of this run can be found in:
9:47:40 AM: npm
9:47:40 AM: ERR!     /opt/buildhome/.npm/_logs/2020-05-05T07_47_40_546Z-debug.log
9:47:40 AM: ​
9:47:40 AM: ┌─────────────────────────────┐
9:47:40 AM: │        Build failed         │
9:47:40 AM: └─────────────────────────────┘
9:47:40 AM: ​
9:47:40 AM:   Error message
9:47:40 AM:   Command failed with exit code 1: npm run build
9:47:40 AM: ​
9:47:40 AM:   Error location
9:47:40 AM:   In build.command from netlify.toml:
9:47:40 AM:   npm run build
9:47:40 AM: ​
9:47:40 AM: Caching artifacts
9:47:40 AM: Started saving node modules
9:47:40 AM: Finished saving node modules
9:47:40 AM: Started saving pip cache
9:47:40 AM: Finished saving pip cache
9:47:40 AM: Started saving emacs cask dependencies
9:47:40 AM: Finished saving emacs cask dependencies
9:47:40 AM: Started saving maven dependencies
9:47:40 AM: Finished saving maven dependencies
9:47:40 AM: Started saving boot dependencies
9:47:40 AM: Finished saving boot dependencies
9:47:40 AM: Started saving go dependencies
9:47:40 AM: Finished saving go dependencies
9:47:40 AM: Error running command: Build script returned non-zero exit code: 1
9:47:40 AM: Failing build: Failed to build site
9:47:40 AM: failed during stage 'building site': Build script returned non-zero exit code: 1
9:47:41 AM: Finished processing build request in 2m16.3461734s
jlengstorf commented 4 years ago

hmm — at first blush this looks like Gatsby got out of sync with itself somehow

if this were my site, I would:

  1. run npm outdated to see if there are any packages that need updates
  2. run npm update to bump them to latest
  3. if that doesn't fix it, use the "clear cache and deploy" option on Netlify
  4. make sure that it doesn’t happen again on repeat builds

if that doesn't work, let me know and we can dig deeper into this

thanks!

jlengstorf commented 4 years ago

I haven't seen any additional reports of this failure, and my sites are building properly, so I'm going to close this. please let me know if you're still hitting this issue!

imnotdannorton commented 3 years ago

I am encountering this issue at the moment. building on Netlify, trying to empty cache and rebuild, and seeing this part of the output:

3:53:04 PM: Fetch Contentful data: 14896.313ms
3:53:15 PM: success Checking for changed pages - 0.000s
3:53:15 PM: success source and transform nodes - 25.252s
3:53:19 PM: success building schema - 4.163s
3:53:20 PM: error "gatsby-node.js" threw an error while running the createPages lifecycle:
3:53:20 PM: ENOENT: no such file or directory, open '/opt/build/repo/.cache/contentful/assets/dunkin-2e781274fe09ee94ecf97835fb78087c.png'

this is rather frustrating, as I had hoped removing a previous asset that had been throwing the same error and replacing it with a new one would solve the issue. but alas, here we are. All of the contentful assets have been published -- I am going to see if removing the GATSBY_EXPERIMENTAL_PAGE_BUILD_ON_DATA_CHANGES flag will at least allow a publish without issue.

imnotdannorton commented 3 years ago

removing the flag didn't help 😢

jlengstorf commented 3 years ago

@imnotdannorton does it build if you disable this plugin? if a clear cache isn't working, that feels like it might be a contentful issue?

imnotdannorton commented 3 years ago

@jlengstorf thanks for the reply; I guess that's where I am getting confused, if Gatsby is getting the reference to this item from Contentful (where it does in fact exist, although the filename when uploaded does not have the hash at the end), what part of the build process is causing it to fail? the server trying to download it and put it in this build repo?

I commented here because I thought it had something to do with the cache, but it appears to have the same issue regardless whether or not it's enabled. I opened another issue earlier with the full logs here: https://github.com/gatsbyjs/gatsby/issues/28804

Just trying to debug what service is acting strange and how to go about adjusting. Seems odd that making a change to an asset in Contentful would cause this error. Thanks again!

jlengstorf commented 3 years ago

unfortunately I don't know enough about how the Contentful plugin works to be useful here. if I had to guess, the plugin has some logic to generate assets and it's skipping the generation for some reason but tracking as if it's been generated?

good luck!