Gatsby v4 Builds suddenly killed, exit code 137

Hi everyone. All of my Gatsby v4 sites suddenly had their builds start to fail due to an error “Command failed with exit code 137”. This wasn’t happening just last week, I’ve tried rebuilding from commits that had built successfully recently on multiple projects and now they all break.
From what I read, this error seems to be related to memory issues, but the websites are very small (one of them is 3 pages, the whole data from Sanity is 6MB, assets included), and the fact that they used to build successfully and that this started happening in multiple projects at once makes me think this is something that changed on Netlify’s side.
Also, all my Gatsby v2 or v3 website still build successfully, but again, it’s not just a Gatsby problem as I didn’t upgrade it anytime recently in these projects that are failing, most of them were always Gatsby v4 projects and worked fine thus far.

Here’s the full log for one of my failed builds (for one of my projects): Netlify failed build, exit code 137 · GitHub
And here’s the full log for a successful build based on the same commit: Netlify successful build · GitHub

Can you please give me some guidance? I have multiple projects stalled due to this problem.

I tried running using the command npx process-top ./node_modules/.bin/gatsby build instead of yarn build to see whether there was some crazy memory usage going on but it doesn’t seem like it, it didn’t even hit 1GB, so I see no reason for the build to fail, it really seems to be a Netlify problem (triggered by some Gatsby 4 behaviour but still).

You can see the logs for this build here: Netlify failed build, exit code 137, with npx process-top · GitHub
Note: the build seems to succeed, but in fact it fails but the npx process-top seems to swallow the error.

Hey there, @fvieira :wave:

Thanks for reaching out about this. Sorry to hear you are encountering obstacles. Can you please share your project repo? This will help us look into your setup further.

Sure, I’ll send you the code for one of our Gatsby v4 projects over a private message.

Hi @fvieira

Not sure what your tool is reporting, but you’re definitely needing much more than 1 GB RAM:

8 GB to be specific, where the build finally gives up and fails.

This is the graph showing memory usage for your build (the gist that you shared).