Issue #3637646: BigPipe can run a library before a library it depends on

Runs the BigPipe replacements one after the other, so a replacement cannot add its scripts before an earlier replacement has added a library they depend on.

processReplacement() now chains Drupal.bigPipe.commandExecutionQueue() on one promise. A replacement that fails, for example because a stylesheet cannot be loaded, is logged with console.error() and does not stop the next one.

The test commit adds BigPipeRegressionTest::testReplacementOrder() with three placeholders: one whose stylesheet cannot be loaded, one with a slow stylesheet, and one whose library depends on the second. It fails without the fix, and also when the chain does not catch the failed replacement. The fix applies to 11.x unchanged.

Known limitation: each replacement now waits for the CSS and JavaScript of the replacements before it. That keeps stylesheets, scripts and behaviors in document order, as on a page without BigPipe, and a stylesheet that never loads also holds back the later replacements, like a render-blocking stylesheet in <head>. Ordering only the replacements that add JavaScript would let a later stylesheet overtake an earlier one and change the cascade.

Closes #3637646

AI disclosure: This contribution was human-driven, AI-assisted, human-reviewed and tested in a real project.

Edited by hans rossel

Merge request reports

Loading
Loading