Skip to content

fix: avoid buffering RSC payloads via unused tee branches in renderHTML#162

Merged
uhyo merged 1 commit into
masterfrom
claude/issue-146-vc34hk
Jul 21, 2026
Merged

fix: avoid buffering RSC payloads via unused tee branches in renderHTML#162
uhyo merged 1 commit into
masterfrom
claude/issue-146-vc34hk

Conversation

@uhyo

@uhyo uhyo commented Jul 21, 2026

Copy link
Copy Markdown
Owner

Closes #146

Problem

renderHTML in packages/static/src/ssr/entry.tsx unconditionally teed the incoming RSC stream, but the second branch was only consumed in dev mode when no clientRscStream was provided. In two cases the branch was never read or cancelled:

  • build mode (options.build === true): the payload injection step is skipped entirely;
  • dev non-SSR (clientRscStream provided): the shell stream's second branch was unused.

An unread tee() branch causes the stream implementation to queue every chunk for it without bound, so the entire RSC payload was buffered in memory per render (per entry during builds).

Fix

Only tee the stream when the inline injection branch will actually be consumed (dev mode without a separate clientRscStream). Otherwise the original stream is passed directly to createFromReadableStream, and the injected stream (if any) is the caller-provided clientRscStream.

Testing

  • pnpm typecheck, pnpm lint, pnpm test:run — all pass
  • pnpm test:e2e (31 tests) and pnpm test:e2e:dev (28 tests) — all pass, covering build+SSR, build+no-SSR, and both dev modes

🤖 Generated with Claude Code

https://claude.ai/code/session_01HMVhUo2qQedCq79R4Ks6zh


Generated by Claude Code

renderHTML unconditionally teed the incoming RSC stream, but the second
branch was only consumed in dev when no clientRscStream was provided. In
build mode and in dev non-SSR mode the unread tee branch caused the
stream implementation to buffer the entire RSC payload in memory (per
entry during builds). Now the stream is only teed when the inline
injection branch will actually be consumed.

Closes #146

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HMVhUo2qQedCq79R4Ks6zh
@uhyo
uhyo merged commit 64c57d0 into master Jul 21, 2026
2 checks passed
@uhyo
uhyo deleted the claude/issue-146-vc34hk branch July 21, 2026 14:18
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.

renderHTML: unused tee branches buffer entire RSC payloads in memory

2 participants