Skip to content

fix: run section loaders for nested sections recursively#34

Open
JonasJesus42 wants to merge 1 commit intomainfrom
JonasJesus42/nested-loader-fix
Open

fix: run section loaders for nested sections recursively#34
JonasJesus42 wants to merge 1 commit intomainfrom
JonasJesus42/nested-loader-fix

Conversation

@JonasJesus42
Copy link
Copy Markdown
Contributor

@JonasJesus42 JonasJesus42 commented Mar 23, 2026

Summary

  • runSingleSectionLoader now recursively detects nested sections in resolved props ({ Component, props } shape from normalizeNestedSections) and runs their registered loaders
  • Fixes wrapper sections like BackgroundWrapper whose child sections (e.g. CategoryBanner) never had their loaders invoked
  • Nested loaders run in parallel via Promise.all; leaf sections with no nested children incur zero extra allocation (same reference returned)

Test plan

  • Verify a page with BackgroundWrapper > CategoryBanner renders the banner correctly without a site-level workaround
  • Verify top-level section loaders still work as before (layout, cacheable, regular)
  • Verify deeply nested sections (wrapper inside wrapper) also get their loaders run

🤖 Generated with Claude Code


Summary by cubic

Recursively run section loaders for nested sections found in resolved props to ensure child sections inside wrappers load their data and render correctly (e.g., BackgroundWrapper > CategoryBanner).

  • Bug Fixes
    • runSingleSectionLoader now walks props to detect normalized nested sections ({ Component, props }) and runs their loaders.
    • Handles arrays and deep nesting; runs nested loaders in parallel with Promise.all.
    • Keeps existing layout/cacheable/regular behavior and error handling; leaf sections avoid extra allocations.

Written for commit c84d57c. Summary will update on new commits.

runSingleSectionLoader now walks resolved props after running a sections
own loader, detects nested sections ({ Component, props } shape from
normalizeNestedSections), and recursively runs their registered loaders.
This fixes wrapper sections like BackgroundWrapper whose children never
had their loaders invoked.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 1 file

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="src/cms/sectionLoaders.ts">

<violation number="1" location="src/cms/sectionLoaders.ts:355">
P2: `enrichNestedSections` only inspects direct prop values and array items, but `normalizeNestedSections` in resolve.ts produces `{ Component, props }` at arbitrary depths inside plain objects. Nested sections inside non-section objects (e.g. `props.config.banner`) will silently skip loader enrichment. Consider adding an `else if (typeof value === 'object')` branch that recurses into plain objects.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread src/cms/sectionLoaders.ts
key: value.Component,
};
promises.push({ key, promise: runSingleSectionLoader(nested, request) });
} else if (Array.isArray(value)) {
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot Mar 23, 2026

Choose a reason for hiding this comment

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

P2: enrichNestedSections only inspects direct prop values and array items, but normalizeNestedSections in resolve.ts produces { Component, props } at arbitrary depths inside plain objects. Nested sections inside non-section objects (e.g. props.config.banner) will silently skip loader enrichment. Consider adding an else if (typeof value === 'object') branch that recurses into plain objects.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/cms/sectionLoaders.ts, line 355:

<comment>`enrichNestedSections` only inspects direct prop values and array items, but `normalizeNestedSections` in resolve.ts produces `{ Component, props }` at arbitrary depths inside plain objects. Nested sections inside non-section objects (e.g. `props.config.banner`) will silently skip loader enrichment. Consider adding an `else if (typeof value === 'object')` branch that recurses into plain objects.</comment>

<file context>
@@ -266,38 +266,127 @@ export async function runSectionLoaders(
+        key: value.Component,
+      };
+      promises.push({ key, promise: runSingleSectionLoader(nested, request) });
+    } else if (Array.isArray(value)) {
+      for (let i = 0; i < value.length; i++) {
+        const item = value[i];
</file context>
Fix with Cubic

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.

1 participant