fix(develop): emit stale page data messages when staticQueryHashes change #28349
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
Currently we don't reprocess page-data's
staticQueryHashes
array in develop when those change, which means if we have cached page-data we will not handle fetching any additions to that array. If the new static queries are not cached already this results in "Cannot fetch static query result", which can be fixed by refresh (but is bad experience of course).This will mark cached pageData entries as stale which will cause dev runtime to refetch it next time
loadPage
is called instead of using (now stale) cached result and run all the regular processing (which will fetch static queries that are not fetched/cached yet).This is not complete fix however. It doesn't exactly fix the problem when
staticQueryHashes
changed for a page user currently view in the browser ( note TODO comments I added in added e2e test scenario and dev-loader ), but it handles at least some cases.Note - I initially thought this is query on demand specific problem, but it's not - it's generic problem (so changes in loader.js to refetch stale data had to be expanded to
gatsby develop
when not using query on demand)The e2e test file changes are best checked with "Hide whitespace changes" ( https://github.com/gatsbyjs/gatsby/pull/28349/files?w=1 ) because I just did wrap existing test with additional
cy.describe
to mark that those are due to data updates and new block cover case of adding static query topage-data
(which originates from source code changes and not data changes)