There is this check in the attach() function

  Drupal.behaviors.autologout = {
    attach: function (context, settings) {
      if (context !== document) {
        return;
      }
....

Which is attempting to only run the autologout JS behavior once only when the current context is the main DOM "document" / html.

However with big pipe enabled, there can be multiple calls to attach JS behaviors with the document as the context leading to some odd race conditions. (In my case, during the logout process where I see some database locking while 3 different requests try to log out at the exact same time).

To mitigate this, can we use Drupal.once on the html element instead.

CommentFileSizeAuthor
#6 after_change.png30.29 KBthtas
#6 before_change.png35.15 KBthtas

Issue fork autologout-3570232

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

thtas created an issue. See original summary.

thtas changed the visibility of the branch 3570232-attach-js-only to hidden.

thtas changed the visibility of the branch 3570232-attach-js-only to active.

thtas changed the visibility of the branch 8.x-1.x to hidden.

thtas’s picture

StatusFileSize
new35.15 KB
new30.29 KB

My network console showing the issue.

Before patch

Before change

After patch

After change

thtas’s picture

Status: Active » Needs review

the_g_bomb made their first commit to this issue’s fork.

the_g_bomb’s picture

Status: Needs review » Needs work

This will need a rebase.

deaom’s picture

Went and rebased this and when solving conflicts discovered this was already solved. The original MR adds if (once('autologout-js', 'html', context).length === 0) { return; } but the code already on the 2.x branch solves it like

const [body] = once('autologout-once', 'body');
      if (!body) {
        return;
      }

So there is no longer a need for this correction as it's already there. I'll leave status as is so maintainer can close it as they wish.

the_g_bomb’s picture

Status: Needs work » Fixed

As per the previous comment, the other work done has solved this. Please feel free to reopen and update the steps to reproduce if you are still having problems.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.