Repository navigation
fix(solid-js): harden streaming wrapper - #804
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthrough
ChangeswrapStream rewrite and streaming setup
Estimated code review effort🎯 4 (Complex) | ⏱️ ~40 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
📦 Bundle Size✅ No notable changes All bundles (12)
⚡ Performance (directional)✅ No significant change (within CI noise) All benchmarks (6)
Baseline: main @ 49ccade · 2026-06-28 · gzipped is the headline size metric · perf is directional (shared-runner, gated) |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
packages/solid-js/src/stream/server.ts (1)
143-145: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick winAvoid quadratic flushing of buffered chunks.
Repeated
shift()reindexes the array for every buffered chunk. Iterate and clear the buffer instead.Suggested change
- while (bufferedChunks.length) { - controller.enqueue(bufferedChunks.shift()!) - } + for (const chunk of bufferedChunks) { + controller.enqueue(chunk) + } + bufferedChunks.length = 0🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/solid-js/src/stream/server.ts` around lines 143 - 145, The buffered chunk flush in server streaming is doing repeated array reindexing via bufferedChunks.shift(), which can become quadratic. Update the flush logic in the streaming path around the bufferedChunks loop to iterate through the existing items and then clear the buffer afterward, using the existing controller.enqueue flow without mutating the array per item.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/solid-js/src/stream/server.ts`:
- Around line 190-192: The catch block in the server stream path currently calls
fail(error) immediately, which can discard already buffered chunks from the
ReadableStream. Update the error handling in the stream logic around the catch
path so that buffered shell/app output is allowed to drain before the stream is
failed, or explicitly make this behavior intentional with a test. Use the
surrounding stream flow in server.ts and the relevant ReadableStream
controller/fail handling to locate the fix.
In `@packages/solid-js/test/e2e-streaming.test.ts`:
- Line 9: Tighten the XSS check by broadening XSS_RE in e2e-streaming.test.ts so
it matches any unexpected script tag, not just a specific
<title>...<script>alert... pattern. Update the assertion logic around the XSS
test cases to detect script tags with attributes, line breaks, or scripts
emitted outside the title, using the XSS_RE constant and the related test
expectations near the affected assertions.
---
Nitpick comments:
In `@packages/solid-js/src/stream/server.ts`:
- Around line 143-145: The buffered chunk flush in server streaming is doing
repeated array reindexing via bufferedChunks.shift(), which can become
quadratic. Update the flush logic in the streaming path around the
bufferedChunks loop to iterate through the existing items and then clear the
buffer afterward, using the existing controller.enqueue flow without mutating
the array per item.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 92d82874-deed-4ea2-b7bb-49f823427508
📒 Files selected for processing (3)
packages/solid-js/src/stream/server.tspackages/solid-js/test/e2e-streaming.test.tspackages/solid-js/test/streaming.test.ts
There was a problem hiding this comment.
🧹 Nitpick comments (1)
examples/vite-ssr-solidjs-streaming/src/components/Reviews.tsx (1)
25-34: 🔒 Security & Privacy | 🔵 Trivial | ⚡ Quick winUse
textContentfor the JSON-LD script.Line 28 uses
innerHTMLon anapplication/ld+jsonentry. That works with the current numeric payload, but it skips Unhead’s safer JSON-LD serialization path and makes this example easy to cargo-cult into an XSS bug once string fields get added later.Suggested change
script: [ { type: 'application/ld+json', - innerHTML: JSON.stringify({ + textContent: JSON.stringify({ '`@context`': 'https://schema.org', '`@type`': 'AggregateRating', ratingValue: DATA.avgRating, reviewCount: DATA.reviews.length, }),🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@examples/vite-ssr-solidjs-streaming/src/components/Reviews.tsx` around lines 25 - 34, The JSON-LD script in Reviews should not use innerHTML for the application/ld+json entry. Update the script object to use textContent instead so the Unhead JSON-LD path is used safely, and keep the change in the Reviews component where the schema.org AggregateRating object is built.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@examples/vite-ssr-solidjs-streaming/src/components/Reviews.tsx`:
- Around line 25-34: The JSON-LD script in Reviews should not use innerHTML for
the application/ld+json entry. Update the script object to use textContent
instead so the Unhead JSON-LD path is used safely, and keep the change in the
Reviews component where the schema.org AggregateRating object is built.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: c316fa61-e35c-442b-bd88-f319a646181e
📒 Files selected for processing (4)
examples/vite-ssr-solidjs-streaming/index.htmlexamples/vite-ssr-solidjs-streaming/src/components/Reviews.tsxexamples/vite-ssr-solidjs-streaming/src/entry-client.tsxexamples/vite-ssr-solidjs-streaming/vite.config.ts
✅ Files skipped from review due to trivial changes (1)
- examples/vite-ssr-solidjs-streaming/index.html
🔗 Linked issue
Related to #789
❓ Type of change
📚 Description
Splits the Solid streaming wrapper work from the broader streaming contracts branch into a focused
@unhead/solid-jsPR.wrapStreamnow reads the app stream as soon as the wrapper starts, buffers app chunks untilonCompleteShell, forwards inner stream errors before and after shell completion, cancels the inner reader when the outer stream is cancelled, and releases the inner reader on completion. The Solid streaming tests cover those cases, and the existing Solid e2e streaming test now imports the Solid integration instead of the core stream helpers.Summary by CodeRabbit
wrapStreamcoverage for inner errors (before/after shell readiness), cancellation propagation, and completion behavior.#rootand adjust JSON-LD injection behavior.