Content unlocking when leaving the page does not work in Chrome 80

Created on 7 April 2020, over 5 years ago
Updated 11 June 2025, about 2 months ago

Chrome 80 has enabled a setting that disallow sync XHR requests in onunload event and it breaks the unlocking functionnality when leaving the page because the ajax request is not sent anymore.

Currently the request is intentionally made synchronous in the js/content_lock_init.js file at line 16:

        jQuery.ajax({
          url: Drupal.settings.basePath + 'ajax/content_lock/' + nid + '/canceledit',
          data: {k: ajax_key, token: Drupal.settings.content_lock.token},
          async: false,
          cache: false
        });

Async requests are not allowed in Edge and Firefox, IE11 accepts both, so today it seems not possible anymore to have a unified way to send this request, but maybe I am missing something.

It may be possible to do something with the sendBeacon function, that should be supported by all the main web browser but IE 11 and opera mini. It needs work because the current request use the GET method and it still requires a workaround for some browsers.

I didn't test the other versions but 7.3 should also be affected because it has the same code.

πŸ› Bug report
Status

Closed: outdated

Version

2.0

Component

Code

Created by

πŸ‡¨πŸ‡­Switzerland faeby

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024