Skip to content

fix: guard registerSectionsSync against non-callable default exports - #9

Merged
JonasJesus42 merged 4 commits into
mainfrom
JonasJesus42/fix-register-sync-guard
Mar 13, 2026
Merged

JonasJesus42 merged 4 commits into
mainfrom
JonasJesus42/fix-register-sync-guard

Conversation

@JonasJesus42

@JonasJesus42 JonasJesus42 commented Mar 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Adds a defensive typeof entry.default === "function" check in registerSectionsSync
  • If a module object has no callable default export, it is skipped with a console warning instead of silently registering undefined as the component
  • Prevents downstream render errors when section module objects lack a default export

Context

v0.21.0 shipped the deferred section cache and registerSectionsSync accepting full module objects, but missed this guard. Storefronts using direct imports work fine, but module re-exports without a default can silently break rendering.

Test plan

  • Verify sections still render normally with standard imports
  • Pass a module object without .default and confirm warning is logged + section is skipped

Generated with Claude Code


Summary by cubic

Add a strict guard in registerSectionsSync to only register valid components. Accept functions and React.memo/forwardRef/lazy (whitelisted via $$typeof); modules without a callable default export are skipped with a console warning to prevent undefined registrations and render errors.

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

When a module object passed to registerSectionsSync has no callable
default export, the old code silently registered undefined as the
component. Now it checks typeof entry.default === 'function' and
skips with a warning, preventing downstream render errors.

Co-Authored-By: Claude Opus 4.6 <[email protected]>

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

Copy link
Copy Markdown

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/registry.ts">

<violation number="1" location="src/cms/registry.ts:166">
P1: This guard rejects valid `React.memo`/`forwardRef` default exports because those component wrappers are not plain functions. A sync section module exporting one of those wrappers will now be skipped and never render.</violation>
</file>

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

Comment thread src/cms/registry.ts Resolved
The typeof === "function" check rejected React.memo and forwardRef
default exports since those wrappers are objects, not functions.
Now accepts any truthy non-primitive value (identified by cubic).

Co-Authored-By: Claude Opus 4.6 <[email protected]>

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

Copy link
Copy Markdown

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 (changes from recent commits).

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/registry.ts">

<violation number="1" location="src/cms/registry.ts:166">
P1: `typeof raw === "object"` still registers invalid module defaults like `{}` as components, so malformed section modules can continue to fail at render time.</violation>
</file>

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

Comment thread src/cms/registry.ts Resolved
Plain objects like {} would pass the previous typeof === "object"
check. Now requires $$typeof — the marker React.memo, forwardRef,
and lazy all set (identified by cubic).

Co-Authored-By: Claude Opus 4.6 <[email protected]>

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

Copy link
Copy Markdown

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 (changes from recent commits).

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/registry.ts">

<violation number="1" location="src/cms/registry.ts:168">
P2: This guard still accepts arbitrary `$$typeof` objects, so some invalid default exports will continue to be registered as components.</violation>
</file>

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

Comment thread src/cms/registry.ts Resolved
Whitelist react.memo, react.forward_ref, react.lazy instead of
accepting any object with $$typeof (identified by cubic).

Co-Authored-By: Claude Opus 4.6 <[email protected]>

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

Copy link
Copy Markdown

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 (changes from recent commits).

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/registry.ts">

<violation number="1" location="src/cms/registry.ts:165">
P2: Do not whitelist `React.lazy` in `registerSectionsSync`. This path renders the component as already-synchronous, so a lazy export can still suspend or show fallback unexpectedly.</violation>
</file>

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

Comment thread src/cms/registry.ts
Comment on lines +165 to +168
const REACT_WRAPPERS = [
Symbol.for("react.memo"),
Symbol.for("react.forward_ref"),
Symbol.for("react.lazy"),

@cubic-dev-ai cubic-dev-ai Bot Mar 13, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: Do not whitelist React.lazy in registerSectionsSync. This path renders the component as already-synchronous, so a lazy export can still suspend or show fallback unexpectedly.

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

<comment>Do not whitelist `React.lazy` in `registerSectionsSync`. This path renders the component as already-synchronous, so a lazy export can still suspend or show fallback unexpectedly.</comment>

<file context>
@@ -161,11 +161,17 @@ export type SyncSectionEntry =
-    // Accept functions and React wrapper objects (React.memo, forwardRef, lazy
-    // which have a $$typeof symbol marker)
+    // Accept functions and React wrapper objects (React.memo, forwardRef, lazy)
+    const REACT_WRAPPERS = [
+      Symbol.for("react.memo"),
+      Symbol.for("react.forward_ref"),
</file context>
Suggested change
const REACT_WRAPPERS = [
Symbol.for("react.memo"),
Symbol.for("react.forward_ref"),
Symbol.for("react.lazy"),
const REACT_WRAPPERS = [
Symbol.for("react.memo"),
Symbol.for("react.forward_ref"),
];
Fix with Cubic

@JonasJesus42
JonasJesus42 merged commit ddab08f into main Mar 13, 2026
1 check passed
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 0.21.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

guitavano added a commit that referenced this pull request Nov 17, 2026
…anStack Start, esbuild) (#832)

Closes the open Dependabot alerts in one PR, with the lockfile. The
Dependabot PRs (#811, #828, #747) only touch `package.json`, so they all
fail `bun install --frozen-lockfile` in CI.

| Package | From | To | Alerts |
|---|---|---|---|
| `react-server-dom-webpack` (tanstack-rsc-smoke) | 19.2.7 | 19.2.9 |
#19, critical: RSC RCE, GHSA-xqc2-xf4c-x3h3 |
| `react` / `react-dom` (all pinned workspaces) | 19.2.7 | 19.2.9 | peer
floor of the above |
| `next` (nextjs, compat-v7, nextjs-binding-smoke) | 16.3.8 | 16.4.6 |
#10–12, #14, #15, #17, #18, #20–22 |
| `@tanstack/react-start` (tanstack, compat-v7, smokes) | 1.168.58 |
1.168.61 | #2–4, #7, #9 |
| `@tanstack/react-router` | 1.170.39 | 1.170.42 | the version
react-start 1.168.61 pins, so it stays a single copy |
| `esbuild` (blocks, tanstack, compat-v7) | ^0.27.3 | ^0.28.2 | #5, #6,
#8 (low) |

`bun.lock` was regenerated with bun 1.3.5 (the `packageManager`). React
dedupes to a single 19.2.9 at the root, with no nested copies. Vite
still has its own transitive `[email protected]` (its own range); that is
outside our manifests.

Supersedes #811, #828 and #747.

### Verified locally (bun 1.3.5, node 24)
- `bun install --frozen-lockfile` ✅
- `bun run typecheck` ✅ · `bun run lint` ✅
- `bun x vitest run`: 3388 passed, 0 failed ✅ (includes
`tests/release.test.ts`)
- `examples/tanstack-worker-smoke`: build + smoke ✅
- `examples/nextjs-binding-smoke`: build + smoke ✅
- `examples/tanstack-rsc-smoke`: build + typecheck ✅

🤖 Generated with [Claude Code](https://claude.com/claude-code)

<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Bumps several dependencies to clear open Dependabot security alerts,
including a critical RCE in `react-server-dom-webpack`
(GHSA-xqc2-xf4c-x3h3). The lockfile was regenerated so `bun install
--frozen-lockfile` passes — React dedupes to a single 19.2.9 copy.

**Dependencies**
- `react`, `react-dom`, and `react-server-dom-webpack` 19.2.7 → 19.2.9
- `next` 16.3.8 → 16.4.6
- `@tanstack/react-start` 1.168.58 → 1.168.61, with
`@tanstack/react-router` 1.170.42
- `esbuild` ^0.27.3 → ^0.28.2; Vite's own transitive `[email protected]` is
untouched
- Typecheck, lint, the full test suite (3388 passed), and the Next.js
and TanStack smoke builds all pass

<sup>Written for commit 123acc8.
Summary will update on new commits.</sup>

<a href="https://cubic.dev/pr/decocms/blocks/pull/832?utm_source=github"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img
alt="View guided diff"
src="https://www.cubic.dev/buttons/review-in-cubic-light.svg"></picture></a>
<a
href="https://www.cubic.dev/action/auto-fix/pr/decocms/blocks/832?returnTo=https%3A%2F%2Fgithub.com%2Fdecocms%2Fblocks%2Fpull%2F832&source=description"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"><img
alt="Turn on auto-fix"
src="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"></picture></a>

<!-- End of auto-generated description by cubic. -->

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant