Skip to content

Keep executor when chained page contributions end with a non-hydrated component - #2323

Open
alansemenov wants to merge 1 commit into
6.xfrom
executor-chain-2322
Open

alansemenov wants to merge 1 commit into
6.xfrom
executor-chain-2322

Conversation

@alansemenov

Copy link
Copy Markdown
Member

Fixes #2322

Problem

In the custom flow, when the result of one renderPageContributions call is passed as pageContributions into the next, the executor script is dropped as soon as a later call is for a component that does not need JS (ssr without hydrate, or Content Studio edit mode). A hydrated Header followed by a static Footer leaves Header un-hydrated: its asset and JSON trigger are in the page, but nothing runs them.

getAndMerge seeds the dedup control set with the executor tag so it can be appended last, which strips it from the incoming contributions, and then only re-appends it when the current call has suppressJS === false.

Fix

Re-append the executor when the current call needs it or the incoming bodyEnd already contained it. The executor still lands last and is still never duplicated.

Tests

New src/jest/server/pageContributions/getAndMerge.test.ts covers: executor appended last, not appended when nothing needs it, kept when an earlier rendering needed it and the last one suppresses JS (fails without the fix), and not duplicated when two renderings both need it.

Targets 6.x since the reporting customer is on React4XP 6. The same code exists unchanged on 7.x and master, so this should be forward-ported.

🤖 Generated with Claude Code

… component #2322

getAndMerge strips the executor from incoming page contributions so
it can be appended last, but only re-added it when the current
rendering needed JS. A chain ending with an SSR-only component
therefore lost the executor that an earlier hydrated component
depended on.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@codecov

codecov Bot commented Oct 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (6.x@52aa76d). Learn more about missing BASE report.

Additional details and impacted files
@@          Coverage Diff           @@
##             6.x    #2323   +/-   ##
======================================
  Coverage       ?   22.85%           
======================================
  Files          ?        1           
  Lines          ?       35           
  Branches       ?        0           
======================================
  Hits           ?        8           
  Misses         ?       27           
  Partials       ?        0           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The focused fix correctly addresses the reported regression and includes adequate test coverage.

Review effort: Balanced
Findings: None

What changed in this PR

Preserves the React4XP executor when chained page contributions end with a non-hydrated component.

Changes:

  • Retains and repositions an existing executor last.
  • Adds coverage for suppression, retention, ordering, and deduplication.
File Description
getAndMerge.ts Preserves the executor across chained contributions.
getAndMerge.test.ts Tests executor retention and deduplication.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Chained renderPageContributions drops the executor when the last component has hydrate disabled

2 participants