Skip to content

'contentUpdated' event listener isn't always created due to a race condition #32068

Closed
@navarr

Description

@navarr

Preconditions

  1. Magento 2.3.6
  2. Utilize a JavaScript bundling system (our system uses Advanced Bundling)
  3. Utilize a theme based on theme-frontend-blank
  4. Ensure your bundling system is loading the requirejs config in an element in the
  5. mage/mage should be loaded in the same file that applies the requirejs config

Steps to reproduce

  1. Load a webpage
  2. Place a breakpoint on $("body").on("contentUpdated", function() {
  3. Hard refresh the webpage

NOTE: This does not always work due to a race condition

Expected result

  1. document.getElementsByTagName('body').length is 1

Actual result

  1. In some cases, document.getElementsByTagName('body').length is not 1

Technical Notes

In environments where there are fewer JavaScript files that can be loaded fast enough, mage/mage can be triggered quick to execute before a <body> tag exists in the DOM.

This is due to it being a dependency of, at least, Magento_Theme/js/theme in the blank theme - which is set as a global dependency by the requirejs-config.js file in that theme.

Previous ticket was reported in 2017: #10360


Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.

  • Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.

Metadata

Metadata

Assignees

Labels

Component: FrontendIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedPriority: P2A defect with this priority could have functionality issues which are not to expectations.Progress: doneReproduced on 2.4.2Severity: S1Affects critical data or functionality and forces users to employ a workaround.Severity: S2Major restrictions or short-term circumventions are required until a fix is available.Triage: Dev.ExperienceIssue related to Developer Experience and needs help with Triage to Confirm or Reject it

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions