Skip to content

fix: Return a cancellation-safe web ReadableStream for streaming SSR in development#2206

Merged
birkskyum merged 2 commits into
mainfrom
fix/dev-stream-web-readable
Jul 18, 2026
Merged

fix: Return a cancellation-safe web ReadableStream for streaming SSR in development#2206
birkskyum merged 2 commits into
mainfrom
fix/dev-stream-web-readable

Conversation

@brenelz

@brenelz brenelz commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Fixes #2133

What is the current behavior?

In dev, the handler returns the raw Solid stream object ({ pipe, pipeTo }) from renderToStream. That only renders on Node by accident: h3 falls through to new FastResponse(body), and srvx's Node adapter duck-types .pipe on the body. Under Bun and Deno, srvx's FastResponse is the native Response, which coerces the unknown object via toString() — the whole page body becomes the literal string [object Object].

Reproduced with bun --bun run dev on 2.0.0-beta.2 and verified the mechanism (srvx bun adapter loads, handler takes the return stream branch). On beta.3+ the bug is currently masked by #2183 adding h3 to ssr.noExternal (Vite's module runner then resolves srvx with node conditions even under bun) — this PR makes the behavior correct by contract instead of by accident.

What is the new behavior?

Dev uses the same path as production: pipe through a TransformStream and return a standard web ReadableStream, which every srvx adapter handles. Verified under bun (bun --bun run vite dev) — correct streamed HTML — and under node.

Other information

The removed special case guarded against a dev-server crash when a stream was cancelled mid-flight (from the Devinxi migration, #1942). That no longer reproduces: solid-js ≥1.9's pipeTo catches every write/close, and aborting curl mid-stream with a 5s Suspense boundary under both node and bun leaves the dev server healthy and serving subsequent requests.

Same conclusion as @GregorLohaus's closed #2134, minus the hardcoded content-type header (already set on the event response by createPageEvent) and without keeping a dev/prod divergence. Also related: #2145/#2148/#2163 (same symptom via the deprecated nitro-v2 plugin).

globalThis.USING_SOLID_START_DEV_SERVER now has no remaining readers; left in place to keep this diff minimal.

Full playwright e2e suite in apps/tests (which runs against vite dev and exercises this branch) passes.

🤖 Generated with Claude Code

@netlify

netlify Bot commented Jul 17, 2026

Copy link
Copy Markdown

Deploy Preview for solid-start-landing-page ready!

Name Link
🔨 Latest commit 2f116ed
🔍 Latest deploy log https://app.netlify.com/projects/solid-start-landing-page/deploys/6a5bf8bd967cb700086aefaa
😎 Deploy Preview https://deploy-preview-2206--solid-start-landing-page.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@changeset-bot

changeset-bot Bot commented Jul 17, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 2f116ed

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@solidjs/start Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Jul 17, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@solidjs/start@2206

commit: 2f116ed

brenelz and others added 2 commits July 19, 2026 00:05
The dev path returned the raw Solid stream object ({ pipe, pipeTo })
from renderToStream. That only renders on Node by accident: srvx's
NodeResponse duck-types `.pipe` on the body. Under Bun and Deno, srvx's
FastResponse is the native Response, which coerces the object to the
literal string "[object Object]" - a blank page. Always pipe through a
TransformStream like the production path so h3 receives a standard web
ReadableStream on every runtime.

The special case guarded against a dev-server crash when a stream was
cancelled mid-flight; that no longer reproduces (solid-js's pipeTo
catches every write/close since 1.9), verified by aborting requests
mid-stream under both node and bun with a slow Suspense boundary.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@birkskyum
birkskyum force-pushed the fix/dev-stream-web-readable branch from 0b863e4 to 2f116ed Compare July 18, 2026 22:05
@birkskyum birkskyum changed the title fix: hand h3 a standard ReadableStream in dev fix: Return a cancellation-safe web ReadableStream for streaming SSR in development Jul 18, 2026
@birkskyum
birkskyum merged commit 068b64c into main Jul 18, 2026
10 checks passed
@birkskyum
birkskyum deleted the fix/dev-stream-web-readable branch July 18, 2026 22:44
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.

[Bug?]: Bun create solid results in broken application.

2 participants