Gatsby build fails with exit code 1, but deploy starts and finishes, rendering our app 404

Then gatsby build fails with exit code 1, deploy starts and finishes, rendering our app 404

It should stop and prevent deploy in case of exit 1 code failure as it was before.


We’re facing the same issue with our Gatsby site. Build command exits with status 1 but Cloudflare Pages declares the build as a success and deploys the broken build artifacts.

This is probably the same issue: Build failed with an error, but deployment succeed

1 Like

I’m also facing the same issue (had asked on /r/cloudflare too, apparently I can’t include a link here).

Will be great to have this fixed, since now each deployment is a journey into the unknown :slight_smile:


I am facing the same issue. This is annoying, and my company website stays on 404 for hours. Did you find any fixes for this issue yet?

1 Like

Did you all find any fix for this yet? @alexey.lyakhov @joonas.rouhiainen

No fix yet, having to check the build every time manually until it is fixed by cloudflare.


Same. I’ll probably migrate all my organisation’s website to vercel or netlify if this is not fixed.

Hey @nimish1 @alexey.lyakhov @mnvrth @joonas.rouhiainen

Apologies for missing this thread. Could you give any deployment IDs (the UUID in the URL) or the of a deployment where this happened?

We’re looking into it!


Here’s one deployment where this happened: 0b81c8ee-b54d-40d9-a097-fc77421fe760

Here is my deployment UUID - 5acf9d12-afe9-4707-8cee-1b2830a80992

So from an initial look, I can see Gatsby (or plugin) throwing an exception but it still seems to be exiting with code 0.

I ran a quick build myself and made sure it exited with code 1, the build failed as it should.

This leads us to believe it’s due to Gatsby or related plugin being used. I’m checking to see if we have any contacts over there we can talk to but in the meantime I suggest reporting this to Gatsby as well.

Here’s another one - 84232741-1948-4184-92bd-300d98ce754c (from the logs it seems that the yarn invocation is indeed failing with exit code 1, yet the build continued)

That was my first guess as well, that it could be a Gatsby bug where it exited with code 0 for some reason. But I remember double checking the exit code locally, the output was similar to the CF Pages build and the exit code was indeed 1.

Is it possible that this is related to using build system version 2? Any information would help, because this is making me hesitate a bit before migrating my other projects to to build system 2.

In our case exit code 1 worked perfectly before the outage, then our build has been hanged for more than 24 hours, and after that we started to get successful deploy after exit 1 code. No plugins has been changed.

This is happening for us as well, gatsby build - no change in plugins

Cloudflare Pages is still publishing broken builds where gatsby build finishes with exit code 1.

Hey @Walshy Please look into this further. The issue seems to persist for all of us.

Cloudflare deployment will fail if the public directory is missing, so you can delete it after build failed.

npm run build
if [ $? -eq 0 ]
  echo "Build completed successfully"
  echo "Build failed. Exiting"
  rm -rf public
  exit 1
1 Like