Deploy previews from Github fail when new commits added to open PR

Deploy previews randomly fail with non-zero exit code 2 in situations where I push new commits to an open Pull Request on Github.

Opening the Pull Request always successfully builds the deploy preview. But under certain conditions, pushing new commits to the Pull Request results in build errors that only have a generic exit code, so I can’t see where they’re breaking.

Manually clearing the cache and retrying resolves the issue, but I don’t want to have to do that every time.

Here is an example: Netlify App

This happens on two sites:

  • ilo-ui-react.netlify.app
  • ilo-ui-twig.netlify.app

Both apps use pnpm with turborepo, so I’m wondering if this has something to do with turborepo wanting to use cached assets in a currently existing build?

It does appear to be something to do with .pnpm cache:

https://app.netlify.com/sites/ilo-ui-react/deploys/62e259c3294c2100088c39e0#L629

The files are being loaded from .pnpm folder. Is there a way for you to force pnpm to not use cache? if not, after every build, you can try using rf -rf <the cache folder> so that the cache is not stored (at least not incorrectly).