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:


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:

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).