gutenberg icon indicating copy to clipboard operation
gutenberg copied to clipboard

Gutenberg uses all sockets in Chrome/Edge

Open lkhrs opened this issue 6 years ago • 28 comments

Describe the bug When editing a WordPress website using Gutenberg (using either the stock install or with the Gutenberg plugin installed) in Chrome or Blink-based Edge, refreshing any page on the site will cause the page to be stuck loading forever with a status message of "Waiting for available sockets" in the bottom left corner. The only solution is to restart the browser until it happens again.

Firefox works fine without any issues.

To reproduce Steps to reproduce the behavior:

  1. Open a page or post in Gutenberg
  2. Save the post or page via the "Update" button 3-6 times
  3. Refresh the editor or open the edited page
  4. See error "Waiting for available sockets" status in the bottom left of the browser

Expected behavior Load the page

Screenshots image

Editor version (please complete the following information):

  • WordPress version: 5.4.1
  • Does the website has Gutenberg plugin installed, or is it using the block editor that comes by default? "gutenberg plugin" or "default"
  • If the Gutenberg plugin is installed, which version is it? Latest 8.2.0 (and the default editor)

Desktop (please complete the following information):

  • OS: Windows 10 and Manjaro Linux
  • Browser Chrome, Microsoft Edge using Blink
  • Version Stable and Dev

Additional context I've searched and found a reddit post and a stackoverflow post about the same issue.

Clearing socket pools does not solve the issue and I have to restart the whole browser to continue.

lkhrs avatar May 28 '20 01:05 lkhrs

I will also note that I tested on a vanilla install with the same results. Server stack: Ubuntu 18.04 LTS nginx with php-fpm and MariaDB.

lkhrs avatar May 28 '20 01:05 lkhrs

@lkhrs Thanks for reaching out. This isn't something that I've experienced over quite a long period of using the editor in Chrome.

The editor only uses HTTP requests, so any socket connections would be short-lived.

Are there any plugins you have installed that might be causing this? (though I realise you mentioned a vanilla install).

It's also worth checking for any suspect network activity in the browser dev tools? There's a guide here to debugging network requests if it's something you're not familiar with: https://developers.google.com/web/tools/chrome-devtools/network/

talldan avatar May 28 '20 06:05 talldan

@talldan I tried again this morning on my vanilla install and wasn't able to reproduce the issue, strange.

However, on one of my sites, disabling WooCommerce seems to have made the issue go away.

lkhrs avatar May 28 '20 12:05 lkhrs

I do have the same issue. I switched to the Gutenberg Editor on the test version of our site and regularly run into the "Waiting for Available Sockets" error when I do a sequence of "Save Draft > Preview" steps.

See also here: https://stackoverflow.com/questions/60042585/chrome-waiting-for-available-sockets-firefox-is-fine

caluwaek avatar Jun 10 '20 13:06 caluwaek

@talldan What information do you specifically require? I have a customer that is reporting this issue:

"issue only seen in Chrome which occurs in most cases after/around the 6th save while editing a page. On the 6th/7th save, the website stalls and keeps loading with the message on the bottom left of the browser - waiting for available socket..."

It sounds like Gutenberg is not closing socket connections and eventually they are exhausted (limit of 6).

You might not see this issue in environments where keep-alives are not used or are very short which is the case with a default Apache config (about 5 seconds). In our case we're using an ELB with a large timeout.

macropin avatar Jun 15 '20 23:06 macropin

@macropin I don't think it has yet been established that this is an issue with Gutenberg.

I think the next step is to do some more testing and try to establish what commonalities there are amongst the WordPress installs that have this issue.

Issues like this are often hard to track down, but it might be good if those with the issue could mention what plugins they have installed.

It sounds like Gutenberg is not closing socket connections and eventually they are exhausted (limit of 6).

Not sure that could be possible. As far as I know, the code here uses window.fetch (https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) to make requests, generally to the WordPress REST API. That's a pretty high-level browser API that doesn't offer control over sockets.

talldan avatar Jun 16 '20 03:06 talldan

@macropin Going on the WooCommerce mention from @lkhrs and the reddit conversation in the description, I did some more digging and found this issue: https://github.com/woocommerce/woocommerce/issues/26474

This is describing the same problem (preview triggers a save). The reporter hints that this is a Chrome bug, but that changes to the request when saving a post by the WooCommerce plugin are specifically causing it to trigger.

I'd suggest moving the conversation over to that issue as it looks like nothing can be done here. I'll close this issue.

talldan avatar Jun 16 '20 04:06 talldan

@talldan I'm not using Woocommerce. As for plugins installed : Akismet, Assec Cleanup, Classic Editor, Content Views Pro, Easy Digital Downloads, Polylang, Tablepress, WP Rocket, Yoast.

I should add that this only occurs on the test version of the site, not on our production copy. The issues started occurring after I switched the settings of the classic editor to enable Gutenberg.

caluwaek avatar Jun 16 '20 07:06 caluwaek

Ok, let me reopen this. This does sound like you have an issue with the requests for saving posts not completing in your test environment.

Potentially, the editor should also avoid making more save requests if there are already in progress requests, so there may be some improvements we can make to the code base.

talldan avatar Jun 17 '20 04:06 talldan

I can reproduce this with clicking Update ~6 times in a row on my own test environment.

Screen Shot 2020-06-19 at 10 47 04

If it helps you can check the data here https://netlog-viewer.appspot.com/ by downloading and uploading this log https://gist.githubusercontent.com/oxyc/3cabec7abf1a542d2e382b1eaa43d8cc/raw/7c5c7c8e5188b210965781e7a6897b98d8c86553/gistfile1.txt

Seems the sockets are not closed and afaik 6 is chromes limit. Might be some misconfiguration with my webserver though.

oxyc avatar Jun 19 '20 13:06 oxyc

I figured out it came from a custom Cache Control header I set on my test environments.

  <IfModule mod_expires.c>
    Header set Cache-Control "max-age=0, no-cache, no-store must-revalidate"
    Header set Pragma "no-cache"
    Header set Expires "Wed, 11 Jan 1984 05:00:00 GMT"
  </IfModule>

Just removing the no-store fixes it for me (this has been bugging me for years). Do you have any custom additions to your .htaccess or vhost? Thanks for pointing me to the woocommerce issue @talldan

oxyc avatar Jun 19 '20 14:06 oxyc

I've checked my .htaccess file. Cache-Control is set to public in my case.

caluwaek avatar Jun 19 '20 15:06 caluwaek

Could you take a screenshot of the Response headers of a XHR request while it's still succeeding?

Screen Shot 2020-06-19 at 12 26 49

oxyc avatar Jun 19 '20 15:06 oxyc

Here is a screenshot. I noticed I have the same cache-control no-store. I just don't know where it comes from because I see it nowhere in htaccess.

image

caluwaek avatar Jun 19 '20 15:06 caluwaek

You could check if there's a plugin adding it by running this in the project:

grep -r --include '*.php' 'no-store' .

If there's any plugin setting it, try disabling the plugin. Or try disabling cloudflare in case it's somehow set from there.

oxyc avatar Jun 19 '20 16:06 oxyc

I've been experiencing this issue on Chromium based browsers (Google Chrome, Brave browser) for a long time now. I've already made a mental note to use Firefox everytime I'm making a lot of changes on the Wordpress backend, as it doesn't happen on Firefox.

It might be worth noting that everytime I experience this issue, it's:

  • whenever I'm using Google Chrome or Brave
  • working on a local website using Local Lightning (I notice it happens on local, never really noticed the issue when I'm working on production/live sites - but maybe I don't do a lot of work on live sites)
  • making a lot of Save/Publish actions on the backend
  • OS: Windows 10, Manjaro

michaelignacio avatar Jun 26 '20 04:06 michaelignacio

I get the same issue as well. I use the default wordpress configuration Laravel Forge sets up using nginx.

AaronNewcomer avatar Jul 03 '20 02:07 AaronNewcomer

@AaronNewcomer @michaelignacio could you check the response headers for the requests and look for "no-store" in cache control. Like https://github.com/WordPress/gutenberg/issues/22688#issuecomment-646698231

So far this was the cause for 3 users in this issue.

oxyc avatar Jul 03 '20 02:07 oxyc

@oxyc Are you referring to this?

https://i.imgur.com/k95uD0A.png https://i.imgur.com/6b9qcg4.png

michaelignacio avatar Jul 03 '20 03:07 michaelignacio

Yes, that's what caused it here https://github.com/WordPress/gutenberg/issues/22688#issuecomment-646671233, https://github.com/WordPress/gutenberg/issues/22688#issuecomment-646711079 and also WooCommerce users https://github.com/woocommerce/woocommerce/issues/26474.

If you can figure out what is setting it and remove it, it should get fixed.

oxyc avatar Jul 03 '20 09:07 oxyc