Skip to content

Large navigation menus load slowly and exhaust server resources #42904

@dretzlaff

Description

@dretzlaff

Description

Our website has a menu with several submenus linking 30-40 pages in all. Loading the full site editor triggers API requests for ALL the pages. This is quite slow and results in multiple HTTP 508 Resource Limit Is Reached. Requests are CPU-limited on the server and our shared hosting environment limits pending requests to 20. This is ample server resources for everything we need except loading the site editor.

The cause seems to be this feature which decorates items if they point at invalid pages. Each page in the menu gets loaded.
https://github.com/WordPress/gutenberg/pull/31716/files

The HTTP 508 responses typically come from page requests with this stack trace:
useSelect @ data.js
useIsInvalidLink @ block-library.js
NavigationLinkEdit @ block-library.js

I would suggest that loading each page in a menu doesn't scale well. I don't know enough to suggest a path forward, but batching requests or at least limiting their concurrency would solve this.

Step-by-step reproduction instructions

  1. Create a template containing a menu with multiple page links
  2. Open the template in the full site editor.
  3. Note network requests to each referenced page, e.g. wp-json/wp/v2/pages/##?context=edit&_locale=user

Screenshots, screen recording, code snippet

No response

Environment info

WordPress 6.0.1
Chrome 103.0.5060.134
Windows 10.0.19043 Build 19043
Theme twentytwentytwo Version 1.2
Server Linux 3.10.0-962.3.2.lve1.5.38.el7.x86_64 x86_64
Web server Apache
PHP 7.4.30

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions