Skip to content

Gracefully handle WP Engine's Heartbeat API blocking #157

@chrisdfeld

Description

@chrisdfeld

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions