Skip to content

Interactivity API: onDOMReady() throws when performance.getEntriesByType( 'navigation' ) is empty #86476

Closed as not planned

Description

@weblley

Description

Since #71123, the Interactivity API runtime calls onDOMReady( hydrateRegions ) while @wordpress/interactivity is being evaluated (index.ts#L114). onDOMReady() reads the first navigation timing entry without checking that one exists (utils.ts#L90-L100):

const [ navigation ] = performance.getEntriesByType( 'navigation' );
if ( ( navigation as PerformanceNavigationTiming ).domContentLoadedEventStart > 0 ) {

When performance.getEntriesByType( 'navigation' ) returns an empty list, this throws TypeError: Cannot read properties of undefined (reading 'domContentLoadedEventStart'). The rest of the module doesn't run, so no region is hydrated, and the modules that import it (e.g. @wordpress/block-library/navigation/view) fail too: interactive blocks stop working on the page (the Navigation block's overlay menu doesn't open).

We found it through error monitoring (Sentry) on a production site. Every event came from the headless browser Lightpanda (Lightpanda/1.0, used by AI agents and crawlers), which has no navigation timing entry. Regular browsers don't seem to be affected, but jsdom has the same gap: the router's test setup mocks getEntriesByType for this reason (jsdom-setup.ts#L6-L9).

Expected: the runtime doesn't throw when the entry is missing. For example, it could fall back to document.readyState: run the callback when it is complete, otherwise wait for DOMContentLoaded, with load as a backstop for interactive (where it can't tell whether DOMContentLoaded has already fired).

Step-by-step reproduction instructions

  1. Use WordPress 7.1.4 with Twenty Twenty-Five and no plugins. Its header has a Navigation block with the overlay menu, so @wordpress/interactivity loads on the front end.
  2. Make performance.getEntriesByType() return an empty list before the script modules run, for example with this mu-plugin (or open the page in Lightpanda):
    <?php
    add_action( 'wp_head', function () {
    	echo '<script>performance.getEntriesByType = function () { return []; };</script>';
    }, -1000 );
  3. Open the front page and check the console.
  4. Uncaught TypeError: Cannot read properties of undefined (reading 'domContentLoadedEventStart') is logged from interactivity/index.min.js, history.state has no wpInteractivityId, and clicking the Navigation block's menu button does nothing.

Without step 2 there is no error and the menu opens.

Screenshots, screen recording, code snippet

Uncaught TypeError: Cannot read properties of undefined (reading 'domContentLoadedEventStart')
    at Tr (/wp-includes/js/dist/script-modules/interactivity/index.min.js?ver=6a43cba92ed701f32cd9:1:21246)
    at /wp-includes/js/dist/script-modules/interactivity/index.min.js?ver=6a43cba92ed701f32cd9:1:42327

Environment info

  • WordPress 7.1.4. The Gutenberg plugin isn't installed, but onDOMReady() is unchanged in trunk (503ab9f).
  • Twenty Twenty-Five 1.5, no plugins
  • Reproduced in Chromium with the snippet above; seen in production with Lightpanda/1.0

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

  • Yes

Please confirm which theme type you used for testing.

  • Block
  • Classic
  • Hybrid (e.g. classic with theme.json)
  • Not sure

Activity

  1. added
    [Status] In Progress
    on Nov 9, 2026
  2. luisherranz commented on Nov 11, 2026

    @luisherranz
    Member

    I looked into which environments can hit this, and I'm closing it as not planned:

    • The Interactivity API only runs in browsers with native import maps. All of those browsers create the navigation timing entry, so onDOMReady() always finds it in a browser that can run the runtime.
    • Lightpanda added the entry in 1.0.3, released on November 5, so the runtime should hydrate in Lightpanda 1.0.3 and later.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Status] In Progress

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions