fix(gatsby): notify when Gatsby cache is incomplete #27549
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR adds a warning and wipes the
.cache
when thepublic
folder is missing but the.cache
folder exists.Why
Builds can break if someone deletes the
public
folder but not the.cache
(with cryptic errors about missingpage-data
files).There is one case when doing this still leads to accidentally working builds: when the project only has pages without any queries. This behavior actually relies on our "bug" - at the moment we always re-run page queries without dependencies (or in other words - pages without graphql queries in them).
This skipped test sums up the problem:
gatsby/packages/gatsby/src/query/__tests__/data-tracking.js
Lines 1241 to 1243 in ecc0ad3
That's exactly what happens in
gatsby-admin
and ourlong-term-caching
integration tests (we don't have any build-time graphql queries in those and delete thepublic
folder without deleting the.cache
). At the moment this "works" but won't work anymore after #27504 lands (which actually fixes this bug).