-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Avoid synchronous xhr by using window.sendBeacon when available #14994
Conversation
Also seeing this error message appear in my browser console when refreshing the page since upgrading to Chrome 73.0.3683.103. |
Not sure why the CI jobs aren't running for this PR. Will try some force pushing/rebasing to see if I can trigger it. |
9158bcc
to
99526fd
Compare
The problem is no matter what I do, with latest Chrome even, I don't see any error in the console.
This change should make us safe from the incoming updates though |
In the Chromium forum:
So we should merge this as bulletproofing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested the code locally and the posts get unlock fine when the user exits.
Description
While looking at #14986 I noticed an error occurring with one of the preview tests:
Upon some investigation, it looks like this is a change in newer versions of chrome/chromium. Use of synchronous xhr requests have been disallowed in
beforeunload
. Not a great deal of evidence for this change, I found the stack overflow question first and then the thread on the chromium group after that:We're using synchronous xhr requests in
beforeunload
to unlock a post when the page is closed. This fix detects whether thenavigator.sendBeacon
is available, and uses that instead to make the request.How has this been tested?
Use browser dev tool network tab
/wp-admin/admin-ajax.php
was made. The request should have an action of 'wp-remove-post-lock' in its form data.Tail logs
docker logs -f <container_id>
/wp-admin/admin-ajax.php
in the logs when closing the tab (when I tested I added a temporary query string to the url to verify that it was the right request in the logs).Other ways of testing.
beforeUnload
event from the browser console (window.dispatchEvent(new Event('beforeunload'));
) and monitor the network requestsTypes of changes
Bug fix (non-breaking change which fixes an issue)
Checklist: