How to debug webpack job that stops prematurely but is marked as a success

I have a job that is run, and it seems that the output stops prematurely and the job is marked as a success.

Since this job does not do what it needs to do, the next steps fail as they rely on output from this job that is not generated.

The step is building the client JS bundles, it’s a forked version of create-react-app and usually the outpt looks like:

#!/bin/bash -eo pipefail
yarn build
yarn run v1.16.0
$ node ./scripts/build_client.js
Ready to start the build.

Creating an optimized production build...
Compiled successfully.

File sizes after gzip:

  117.64 KB  client/static/js/3.43d276aa.chunk.js
  56.16 KB   client/static/js/0.4d527558.chunk.js
  7.22 KB    client/static/js/4.4136af6f.chunk.js
  3.64 KB    client/static/js/2.f604e0b6.chunk.js
  2.97 KB    client/static/js/jobs.d64ae6cc.chunk.js
  2.41 KB    client/static/js/expert.dd697b06.chunk.js
  1.71 KB    client/static/js/runtime~main.2834295e.js
  1.53 KB    client/static/js/i18n15.db667580.chunk.js
  1.51 KB    client/static/js/i18n3.abe4752b.chunk.js
  1.5 KB     client/static/js/i18n11.50c8baeb.chunk.js
  1.5 KB     client/static/js/i18n7.7ad16bf4.chunk.js
  608 B      client/static/js/1.9cf0186f.chunk.js
  515 B      client/static/js/i18n14.3f7c901c.chunk.js
  515 B      client/static/js/i18n10.efb9045b.chunk.js
  514 B      client/static/js/i18n2.7d484120.chunk.js
  513 B      client/static/js/i18n6.c9bb5c31.chunk.js
  399 B      client/static/js/i18n0.d8cdb2c8.chunk.js
  387 B      client/static/js/i18n12.0aac9e66.chunk.js
  383 B      client/static/js/i18n4.599df3d4.chunk.js
  381 B      client/static/js/i18n8.12f85b16.chunk.js
  338 B      client/static/js/i18n1.5be78fbe.chunk.js
  213 B      client/static/js/i18n13.371bfbe5.chunk.js
  211 B      client/static/js/i18n9.2169a6d2.chunk.js
  210 B      client/static/js/i18n5.954974ed.chunk.js

The project was built assuming it is hosted at https://website.redacted/.
You can control this with the homepage field in your package.json.

The build/client folder is ready to be deployed.

Find out more about deployment here:

  https://bit.ly/CRA-deploy

Done in 34.31s.

When it “fails” it looks like:

#!/bin/bash -eo pipefail
yarn build
yarn run v1.16.0
$ node ./scripts/build_client.js
Ready to start the build.

Creating an optimized production build...
Done in 50.03s.

Also noted is that it often stops around 50s, although often when this task works it completes in around 30s.

What can I do to debug where this is getting stuck? I ran logging up to the point where webpack starts compiling so I imagine it has to do with one of our webpack loaders or webpack configuration or maybe it’s something completely different.

Thanks!