Enhancing WordPress Stability: Addressing Gutenberg Block Editor Preloading Issues

As a Principal Software Architect at Alley, I’m constantly working to ensure the stability and performance of one of the largest WordPress installations in the world. Our team recently tackled a significant issue in the Gutenberg block editor, which prompted a valuable contribution to our open-source plugin, Alleyvate. In this post, I’ll share how I addressed the underlying root cause of a cascading failure and improved the system’s resilience, providing you with practical solutions you can implement on your own WordPress sites.

The Challenge: Cascading Failures in Gutenberg Block Editor

We encountered a critical issue where a single fatal error in one block caused failures across all Gutenberg block edit screens. This was particularly problematic for a site with over 500 reusable blocks (now known as Synced Patterns). The root cause was the pre-loading of these reusable blocks on the edit screen. During pre-loading, the the_content function runs on each block’s post content, causing significant processing overhead and making the system prone to cascading failures.

The Solution: Disabling Pre-loading of Reusable Blocks

To mitigate this issue, we disabled the pre-loading of reusable blocks (synced patterns). This change enhances the overall performance and stability of the WordPress backend for sites with a large number of reusable blocks. For those interested in the technical details, you can check out the code change in our Alleyvate plugin here or view the code for this filter here.

Technical Details

From the Alleyvate plugin README:

disable_block_editor_rest_api_preload_paths

This feature enhances the stability and performance of the block edit screen by disabling the preloading of Synced Patterns (Reusable Blocks). Typically, preloading triggers the the_content filter for each block, along with additional processing. This can lead to unexpected behavior and performance degradation, especially on sites with hundreds of synced patterns. Notably, an error in a single block can propagate issues across all block edit screens. Disabling preloading makes the system more resilient—less susceptible to cascading failures—thus improving overall admin stability. For technical details on how WP core implements preloading, refer to wp-admin/edit-form-blocks.php

Why Alleyvate?

Alleyvate is our open-source plugin designed to set common defaults for WordPress sites we develop and support. It includes modifications to help with scalability and performance, making it an essential tool for enterprise WordPress installations. By leveraging Alleyvate, you can benefit from our solutions to common challenges, ensuring your site remains robust and efficient.

Insights into Enterprise WordPress Engineering

This experience underscores the importance of finding the root cause of issues and addressing them effectively. As an expert web development engineer, I enjoy the detective work involved in uncovering these root causes. Using tools like xdebug, I was able to trace the problem to its source. This scientific approach to problem-solving is crucial, especially for high-traffic news media sites that need to be available 24/7. Publishing and news never take a break, so ensuring the resilience of our systems is paramount.

By addressing the pre-loading issue, we’ve made our site more resilient, limiting the impact of any issues with reusable blocks. This improvement is crucial for maintaining the reliability and availability of a major news site that millions of people rely on for up-to-the-minute information.

For more details and to implement similar solutions, check out our Alleyvate plugin on GitHub.

Stay tuned for more posts about enterprise WordPress, I’ll continue to share insights and solutions to help you manage and scale your WordPress sites effectively.

Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use. To find out more please see our Privacy Policy.