Skip to content

Boot: Keep routes available when the site-data prefetch fails - #86185

Open
LiamSarsfield wants to merge 3 commits into
WordPress:trunkfrom
LiamSarsfield:fix/boot-site-data-prefetch-failure
Open

LiamSarsfield wants to merge 3 commits into
WordPress:trunkfrom
LiamSarsfield:fix/boot-site-data-prefetch-failure

Conversation

@LiamSarsfield

@LiamSarsfield LiamSarsfield commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

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 _fields list, 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

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

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

    <?php
    add_filter(
        'rest_pre_dispatch',
        static function ( $result, $server, $request ) {
            if ( '/' === $request->get_route() ) {
                return new WP_Error( 'test_site_data_failure', 'Test site-data failure.', array( 'status' => 503 ) );
            }
            return $result;
        },
        10,
        3
    );
  3. 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.

  4. Repeat on Settings > Connectors. For the full-page layout, enable the Extensible Site Editor experiment, open wp-admin/admin.php?page=site-editor-v2 and 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.

  5. Remove the mu-plugin. As a control, add a temporary loader to routes/font-list/route.ts that throws new Error( 'Test route loader failure' ), rebuild and reload Fonts. The router still shows that error. Remove it and rebuild.

  6. Reload and move between routes. Fonts loads, and the Home preview and site title come back.

npm run test:unit -- packages/boot and the boot typecheck pass. npm run lint:js on router.tsx reports 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

Before After
Fonts, root request failing
Fonts before
Fonts, root request failing
Fonts after
Connectors, root request failing
Connectors before
Connectors, root request failing
Connectors after
Site Editor (full page), root request failing
Site Editor before
Site Editor Pages, root request failing
Site Editor after

Use of AI Tools

The fix, test and this description were drafted with OpenAI Codex and Claude.

@github-actions github-actions Bot added the [Package] Boot /packages/boot label Nov 2, 2026
@github-actions

github-actions Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

🤖 PR meta 🤖

Preview in WordPress Playground

🎉 Props

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: LiamSarsfield <lsarsfield@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

Updated as activity occurs, without notifying anyone named here. Add the props-bot label to refresh.

@LiamSarsfield

Copy link
Copy Markdown
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

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Boot /packages/boot [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants