Gatsby Build fails on CI (Bitbucket Pipelines)
See original GitHub issueDescription
We try to use Bitbucket Pipelines to build Gatsby.js websites. Time to time (not always) the build fails. The most often error is a segmentation fault:
success open and validate gatsby-configs - 0.040s
/bin/sh: lscpu: not found
success load plugins - 1.755s
success onPreInit - 0.061s
success delete html and css files from previous builds - 0.004s
success initialize cache - 0.009s
success copy gatsby files - 0.060s
success onPreBootstrap - 0.022s
/bin/sh: lscpu: not found
success createSchemaCustomization - 0.016s
success Checking for changed pages - 0.000s
success source and transform nodes - 0.494s
success building schema - 0.439s
success createPages - 0.004s
success Checking for changed pages - 0.000s
success createPagesStatefully - 0.156s
success update schema - 0.241s
success onPreExtractQueries - 0.001s
success extract queries from components - 0.700s
success write out redirect data - 0.005s
success onPostBootstrap - 0.000s
info bootstrap finished - 8.668s
Segmentation fault (core dumped)
Sometimes we get a different error:
success Rewriting compilation hashes - 0.002s
error Generating SSR bundle failed
Can't resolve '../../../../../public/page-data/sq/d/440663142.json' in '/opt/atlassian/pipelines/agent/build/src/components/Features/FeaturesHeader/ParallaxContainer'
If you're trying to use a package make sure that '../../../../../public/page-data/sq/d/440663142.json' is installed. If you're trying to use a local file make sure that the path is correct.
error Generating SSR bundle failed
...
not finished Building static HTML for pages - 3.411s
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! website@0.1.0 build: `gatsby build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the website@0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2020-08-12T07_39_38_453Z-debug.log
Here is the pipeline script we use:
definitions:
steps:
- step: &build
name: Build
image: node:14-alpine
script:
- npm ci --no-audit --progress=false --unsafe-perm
- npm run build
artifacts:
- public/**
pipelines:
default:
- step: *build
Increasing build machine capacity with size: 2x
helps a bit – failed builds appear less often.
Steps to reproduce
To reproduce take a middle-size Gatsby.js project and try to build it inside Bitbucket with the pipeline script described above. It is pretty hard to prepare the exact example for you, though I believe every Gatsby.js website will experience the same problems with pipelines.
Expected result
Build should always be successful.
Actual result
Build sometimes fails.
Environment
The environment is node14-alpine
docker container inside a Bitbucket pipeline.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:9 (2 by maintainers)
Top Results From Across the Web
Sudden new issue. Node / Gatsby Build not able to find path ...
This morning the pipeline failed and has repeatedly failed when it's been triggered automatically and manually. The build process and step run ...
Read more >Build a CI/CD Pipeline for a Gatsby Site - Daniela Baron
Learn how to build a continuous integration and deployment pipeline for a Gatsby site to save time and manual effort.
Read more >I have set up this pipeline on bitbucket to build my Gatsby app ...
We have a bitbucket repo done with React (GatsbyJS), and WP CMS, it builds normally on my local machine, also through SSH on...
Read more >Continuous Deployment - Gatsby
In a continuous deployment system, you don't push a Deploy button or run a deploy command. Instead, you build a pipeline — a...
Read more >CI Build failed at Bitbucket Pipelines CI/CD - Stack Overflow
Already solved, all I had to do was make my project public, the API from those tools was not able to inspect properly...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@artemtam we tried both node:14-alpine and node:15-alpine 😃 But work with “lscpu” utility
# apk search lscpu
util-linux-2.34-r1
# apk add util-linux
For seg faults - not sure if that would work but you can try adding
segfault-handler
package to your (dev)deps, create new file (let’s call itsegfault-debug.js
) in project directory with following content:and adjust build script (in package.json) to be
NODE_OPTIONS=--require=./segfault-debug.js gatsby build
(which should auto-apply that custom script to every node process that gatsby creates).