Repository navigation
Boot: Keep routes available when the site-data prefetch fails - #86185
Open
LiamSarsfield wants to merge 3 commits into
Open
LiamSarsfield wants to merge 3 commits into
LiamSarsfield wants to merge 3 commits into
Conversation
🤖 PR meta 🤖🎉 PropsIf you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
Updated as activity occurs, without notifying anyone named here. Add the |
Contributor
Author
|
@youknowriad would you mind taking a look? It follows on from #81622, for the case where the site data prefetch in the boot router's loader fails. cc @Mamaduka as it's the preload list #80648 synced with core-data. Could one of you also add the [Type] Bug label? I can't add labels here. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What?
Lets a boot route load when the site-data prefetch in its loader fails.
Why?
The boot router's loader waits for
getEntityRecord( 'root', '__unstableBase' )together with the route's own data. When that root request fails, the whole page shows the router's error screen, even though the route doesn't use the result.The request is also easy to break from outside. The page templates preload it under an exact
_fieldslist, and #80648 and #80385 keep that list in sync with core-data in the same checkout. A plugin that ships newer build templates on a site with an older core-data misses the preload, so the page makes a live request, and any failure of it takes the page down. Jetpack's wp-build dashboards hit this on WordPress 7.1 after updating@wordpress/build(worked around in Automattic/jetpack#54396).How?
Catches the rejection of that one prefetch. A successful prefetch still warms the store, and errors from the route's own loader, canvas and title still reach the router as before. The shell renders without site data, and a canvas that needs it shows its own missing-data state.
This doesn't retry. core-data keeps the failed resolution, so the site title and preview stay unavailable until a reload. It also still waits on a request that never settles.
Adds one regression test that fails on the old loader and passes with the catch, declares the Vitest version the repo already uses as a boot dev dependency, and adds a changelog entry.
Testing Instructions
Build Gutenberg and activate it on a local site. As an administrator open Appearance > Fonts (
wp-admin/themes.php?page=font-library-wp-admin) and check it loads.Add this file to
wp-content/mu-plugins/. It fails both the server preload and the live root request, so a matching preload can't hide the failure.Reload Fonts with the Network panel open. The root REST request fails and the font library still renders. On trunk the same failure shows the router's error screen.
Repeat on Settings > Connectors. For the full-page layout, enable the Extensible Site Editor experiment, open
wp-admin/admin.php?page=site-editor-v2and choose Pages. The list and editor canvas work. Home shows its "You attempted to edit an item that doesn't exist" warning while site data is missing, as this change doesn't restore its preview.Remove the mu-plugin. As a control, add a temporary
loadertoroutes/font-list/route.tsthat throwsnew Error( 'Test route loader failure' ), rebuild and reload Fonts. The router still shows that error. Remove it and rebuild.Reload and move between routes. Fonts loads, and the Home preview and site title come back.
npm run test:unit -- packages/bootand the boot typecheck pass.npm run lint:jsonrouter.tsxreports 8 Prettier errors that are already on trunk (trunk has 9, and this change removes one), so I left that formatting alone.Tested on WordPress 7.2-beta3 with this Gutenberg build in Chrome. Not tested on 7.0 or 7.1, without the Gutenberg plugin, or in Firefox and Safari.
Testing Instructions for Keyboard
With the root request failing on Fonts, Tab to Skip to main content and press Enter, Tab to Library, then ArrowRight and Enter. Upload is selected and the Upload font panel renders. No controls are added.
Screenshots or screencast
Use of AI Tools
The fix, test and this description were drafted with OpenAI Codex and Claude.