pristas-peter / wp-graphql-gutenberg

Query gutenberg blocks with wp-graphql
https://wp-graphql-gutenberg.netlify.app
GNU General Public License v3.0
299 stars 62 forks source link

Endless loading trying to update block registry #188

Open PetterEck opened 1 year ago

PetterEck commented 1 year ago

I have noticed that in some of my environments, I sometimes get stuck waiting forever for the registry of blocks to go through. After some debugging, I have noticed that this happens when the heartbeat triggers after page load, meaning that while the timeout is cancelled, the registration step never starts. This seems to happen on low-end systems or otherwise slow environments such as my testing rig. Unfortunately, I don't have a foolproof way of reproducing as it seems to be very environment-dependent.

But I can fix the issue by adding an extra page load dispatch in my Gutenberg build or simply modifying the plugin in the admin.js file like so:

case actions.GET_BLOCK_REGISTRY:
    if (document.readyState === 'complete') {
        onComplete( getBlockRegistry() );
    } else {
        window.addEventListener('load', function() {
            onComplete( getBlockRegistry() );
        });
    }
    break;

It could also have to do with the load order of my environment, but I have not been able to find a way of fixing this issue in this way yet.