Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gracefully handle WP Engine's Heartbeat API blocking #157

Open
chrisdfeld opened this issue Oct 25, 2017 · 1 comment
Open

Gracefully handle WP Engine's Heartbeat API blocking #157

chrisdfeld opened this issue Oct 25, 2017 · 1 comment

Comments

@chrisdfeld
Copy link

Tailor relies on the WordPress Heartbeat API for edit locking, but WP Engine and possibly other web hosts disable Heartbeat except on certain whitelisted WordPress core pages out of performance concerns. Tailor doesn't handle that scenario well and throws a cryptic error. It would be better to detect when the Heartbeat API is blocked (or detect WP Engine specifically) and either provide guidance to the user or use a possible workaround.

Other plugins also warn users of this quirk in documentation, for example: https://eventespresso.com/wiki/setup-wpengine-hosting-event-espresso/

When run on WP Engine, Tailor 1.8.1 throws an Uncaught ReferenceError: sidebarApp is not defined JavaScript console error in canvas.js when attempting to edit a page/post (http://example.com/sample-page/?tailor=1). The errors were different under Tailor 1.7.9 and earlier:

Uncaught TypeError: Cannot read property ‘findWhere’ of undefined
Uncaught TypeError: Cannot read property ‘channel’ of undefined

When these errors crop up, Tailor just shows an all-gray screen with a perpetually spinning circle instead of its editor.

Possible starting point for workaround implementation

Beyond warning the user, the plugin code below might offer a starting point for coding an automatic workaround for this issue. It provides an interface for whitelisting additional WP-Admin URLs that should be allowed to use the Heartbeat API:

https://github.com/PrysPlugins/WPE-Allow-Heartbeat

However, I haven't tested the plugin because WP Engine has already applied a blanket fix to my account.

Background on WP Engine's Heartbeat blocking

Here's what WP Engine's support told me:

The root cause of the issue is that by default, our must-use plugin disables heartbeat, so we have to manually enable it when issues like this happen. Just so that you're aware as well though, enabling heartbeat can potentially cause higher server load and thus lead to a higher load time for the site on the install. In this case though, since it's just related to the page builder plugin that shouldn't be much of a concern, it's generally only problematic if you have other plugins using heartbeat as well.

Immediate fix for WP Engine users

Contact WP Engine's support (live chat is usually quick) and ask them to enable the Heartbeat API so you can use Tailor. They will have references to it in their internal support system.

Possible DIY fix for WP Engine users

It might also be possible to install the whitelist plugin above (https://github.com/PrysPlugins/WPE-Allow-Heartbeat) and add Tailor-specific admin URLs to the whitelist to get this working without the help of WP Engine support in a pinch.

@geoffcourtauld
Copy link

Just to add to this: if you have SFTP access set up to your WP Engine hosting (and you're comfortable tweaking the PHP) within the /wp-content/mu-plugins/ folder you'll find the 'mu-plugin.php' file. Within this if you comment out the following (I'd recommend leaving a comment so any WPE techs know why and by whom this was done) then heartbeat will no longer be restricted:

if ( getenv( 'WPE_HEARTBEAT_AUTOSAVE_ONLY' ) == 'on' ) {
	require_once __DIR__ . '/wpengine-common/class.heartbeatthrottle.php';
	$heartbeat_throttle = new WPE_Heartbeat_Throttle();
	$heartbeat_throttle->register();
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants