Skip to content

fix: preserve scoped classes in production SSR spreads - #974

Merged
trueadm merged 1 commit into
octanejs:mainfrom
openai-oss-forks:fix/ssr-scoped-class-merges
Sep 6, 2026
Merged

trueadm merged 1 commit into
octanejs:mainfrom
openai-oss-forks:fix/ssr-scoped-class-merges

Conversation

@domgan-oai

@domgan-oai domgan-oai commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fix production server rendering dropping synthesized scoped CSS classes on elements with spread attributes. The canonical-attribute fast path returned before applying pending class merges; it now runs only when no class merges are pending.

The ordinary canonical-attribute path remains unchanged. Merge-bearing calls use the existing normalization and class-composition path, preserving authored-class precedence. No compiler, client runtime, or Strong-mode changes.

Validation

  • pnpm install --frozen-lockfile completed with the unchanged lockfile; the earlier registry cooldown no longer blocks installation.
  • Regression red/green: temporarily removing the runtime guard caused all five affected spread variants to fail their emitted-CSS selector match in both octane and octane-prod (10 failures); className remained the unaffected control. Restoring the guard passed all six variants in both projects.
  • pnpm exec vitest run packages/octane/tests/ssr-production-bundle.test.ts packages/octane/tests/ssr.test.ts packages/octane/tests/style-map.test.ts packages/octane/tests/streaming-ssr.test.ts --project octane --project octane-prod --reporter=dot: 300 test executions passed across eight suite executions.
  • pnpm exec tsgo --noEmit -p packages/octane/tsconfig.json.
  • pnpm format:files:check packages/octane/tests/ssr-production-bundle.test.ts packages/octane/src/runtime.server.ts .changeset/ssr-scoped-spread-classes.md and git diff --check.
  • pnpm sync completed without generated changes; the worktree is clean.
  • Current-head CI run passed on 6cf95d710a8715be5cc49ac7a679987493a19223: all four test shards, React parity, website/browser integration, package validation, examples, lint, typechecking, and provenance. Cursor Bugbot also passed with no review threads. The PR is ready for review.
  • Repository-wide pnpm format:check, pnpm typecheck, and pnpm test were not rerun locally; the CI workflow covers the full repository checks.

Performance validation

Compared production SSR fixture bundles with and without the guard using the same installed dependencies on Node 24.18.0, macOS 26.6.2, arm64. Ran the existing harness in baseline/candidate/candidate/baseline order, with 0.2 seconds warmup, 2 seconds timing per case, and 1,000 memory-phase renders:

pnpm exec vite build benchmarks/ssr-throughput/fixtures --ssr src/entry-server.ts --outDir ../dist/fixtures --emptyOutDir
CONFIGS=deopt-page,escape-heavy BENCH_JSON=/tmp/ssr-sample.json node benchmarks/ssr-throughput/run.mjs 2 --no-build

Median render scores (baseline → candidate): compiled cards 1.300 → 1.297 ms (-0.22%); descriptor control 3.458 → 3.461 ms (+0.08%); escaping 3.275 → 3.292 ms (+0.53%). All benchmark gates passed. These small deltas do not establish a throughput change. Full HTML/CSS results matched for both card variants, escaping, and hydratable/static control-flow fixtures. The unminified fixture bundle grew by 24 bytes (178,800 → 178,824).

Risk / follow-ups

This is a one-condition runtime fix with a patch changeset. The measured controls protect ordinary SSR paths; they do not quantify the corrected scoped-class merge path, because the old version omits required output there. Merge-bearing calls use the existing normalization/composition path and its allocations. No throughput improvement is claimed. Self-review confirmed canonical calls without pending class merges retain their fast path and the regression covers empty/null/false/array/className inputs plus authored-class precedence.

Provenance

  • An agent produced this diff (agent-authored)

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.


Note

Low Risk
Single guard on an existing production fast path in SSR attribute serialization; scope is limited to class handling with spreads, with targeted regression tests.

Overview
Fixes production SSR dropping scoped CSS classes on elements that use attribute spreads ({...props}).

In ssrAttrs, the production-only canonical-attribute fast path could return before pending class merges (including synthesized scope-hash classes) were applied. That path now runs only when classMerges === null, so spread/class/className cases go through the full normalization and class-composition logic. Authored-class vs spread precedence behavior is unchanged.

Adds a patch changeset and production-bundle tests (six spread variants) that assert rendered nodes still match emitted scoped selectors and that class before/after spread ordering stays correct.

Reviewed by Cursor Bugbot for commit 6cf95d7. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions github-actions Bot added agent-authored Diff or issue body substantially produced by an AI agent fix PR: bug fix labels Sep 6, 2026
@domgan-oai
domgan-oai marked this pull request as ready for review September 6, 2026 21:37
@trueadm
trueadm merged commit 7a2a2bd into octanejs:main Sep 6, 2026
50 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-authored Diff or issue body substantially produced by an AI agent fix PR: bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants