Gatsby 4.7 build killed command failed with exit code 137

I just upgraded my gatsby site to 4.7 and it builds/serves fine locally.

The site is reverent-fermat-08d36c

When I deployed to Netlify I get a slew of slow query warnings and then get:

12:54:17 PM: Killed
12:54:17 PM: error Command failed with exit code 137.
12:54:17 PM: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
12:54:17 PM: ​
12:54:17 PM: ────────────────────────────────────────────────────────────────
12:54:17 PM:   "build.command" failed                                        
12:54:17 PM: ────────────────────────────────────────────────────────────────
12:54:17 PM: ​
12:54:17 PM:   Error message
12:54:17 PM:   Command failed with exit code 137: yarn build
12:54:17 PM: ​
12:54:17 PM:   Error location
12:54:17 PM:   In Build command from Netlify app:
12:54:17 PM:   yarn build
12:54:17 PM: ​
12:54:17 PM:   Resolved config
12:54:18 PM:   build:
12:54:18 PM:     command: yarn build
12:54:18 PM:     commandOrigin: ui
12:54:18 PM:     environment:
12:54:18 PM:       - ALGOLIA_ADMIN_KEY
12:54:18 PM:       - DISQUS_SHORTNAME
12:54:18 PM:       - GATSBY_ADDTHIS_PUBID
12:54:18 PM:       - GATSBY_ALGOLIA_APP_ID
12:54:18 PM:       - GATSBY_ALGOLIA_SEARCH_KEY
12:54:18 PM:       - GATSBY_CPU_COUNT
12:54:18 PM:       - ROLLBAR_ACCESS_TOKEN
12:54:18 PM:       - ROLLBAR_SERVER_TOKEN
12:54:18 PM:     publish: /opt/build/repo/public
12:54:18 PM:     publishOrigin: config
12:54:18 PM:   headers:
12:54:18 PM:     - for: /*
...

It’s a massive build log, here’s the link to the build:

Any help would be greatly appreciated!
Steve

Hi @agilitynerd

Unfortunately the link provided is to a private log. However, based on the section posted here the following from a thread on the same topic is relevant

If this doesn’t help, there are several other posts referring to code 137 that may.

1 Like

Thanks @coelmay. I’ve copied the log file to a gist and I don’t see any obvious hints as to the cause. I was able to build/deploy earlier today on Gatsby v3 maybe the v4 changes the memory usage(?)

I see the following numerous times through the log

warning This query took more than 15s to run — which is unusually long and might indicate you’re querying too much or have some unoptimized code:

If this wasn’t there using v3 the issue is with v4 and the code you are deploying.

I also see you are using netlify-plugin-gatsby-cache (a now two year old package.) As mentioned in the README, the functionality of this package (and more) is available in Essential Gatsby Plugin.

1 Like

Thanks again @coelmay. I’ve removed the obsolete plugin from my netlify.toml and enabled the Essential Gatsby Plugin in the dashboard. But no change in the build

When I build on Gatsby Cloud I don’t get any query warnings and the site successfully builds/deploys. I’m wondering if the parallel GraphQL query processing changes in the 4.0 Gatsby version don’t work well in the Netlify environment.

My site has 1600 pages and does run some big queries to build index pages, glossary, and summary pages automatically so maybe it’s just too big for the free plan?

I’m thinking I may need to configure Gatsby Cloud to build and then deploy to Netlify instead of trying to build directly on Netlify(?)

Hi there, @agilitynerd :wave:

Thanks for your patience here! Are you still encountering this obstacle? If so, could you please attempt installing Docker image? Once that is installed, please try building locally and see if this helps.

Hi there, @agilitynerd :wave:

Thanks for your patience here! Are you still encountering this obstacle? If so, could you please attempt installing Docker image? Once that is installed, please try building locally and see if this helps.

https://hub.docker.com/r/netlify/build

Hi @hillary,

Yes I still can’t get my site to build on Netlify. I’ve had to change to building locally and I use the netlify cli only to deploy.

If I build using netlify build I get the same dozens of warnings locally and the build fails just like if I build on netlify directly.

But if build using gatsby build I only get two warnings for slow queries and the build completes successfully.

@hillary the instructions for the docker image seem contradictory: Using our tool from the base of a checkout of our build-image repository, Run the image in interactive mode, mounting your repository as a volume: ./test-tools/start-image.sh path/to/my/repo

Since I ran docker pull I don’t have a local checkout of the build-image repo… (and don’t know where to pull it from).

Is there a specific way I should run the docker image?

docker run -it netlify/build just puts me in / and I don’t see any start-image.sh script?

~/dev > docker run -it netlify/build        
buildbot@9de544f144b6:/$ ls
bin  boot  dev	etc  home  lib	lib64  media  mnt  opt	proc  root  run  sbin  srv  sys  tmp  usr  var

I found the github repo and it has complete and usable instructions. Would be helpful if the docker readme was updated.

The build fails with the same logging as on netlify itself:

The process is just killed :person_shrugging:

Hey @agilitynerd,

Thank you for the feedback about the build image docs. We’d try to get some eyes on that.

About your issue, that does seem like the build is running out of memory and sadly there’s no easy fix for it, if at all there’s one. In my experience Gatsby has usually been slower and took more resources than a lot of other site builders, so that fact that you’re failing to build 1600 pages does make sense. Now what you can do about this? Not much actually, but if you want to be 100% sure this is a memory issue, you can try upgrading the memory configuration of the build image that you’re trying locally. If the build works at certain available RAM, you can be sure it’s a RAM issue. If the build always fails no matter what, that’s a different story. But in the first case, you might have to continue building locally and deploy it via CLI.

On the enterprise plan, there’s a HP Build addon that has much more powerful build systems.

@hrishikesh thanks for the candid feedback.

This my personal blog so I’ll either keep building/deploying from my local machine. Or go “hybrid” and build on Gatsby and have them deploy to Netlify (I might be locked in from using the Netlify smart url feature).

Thanks

1 Like