What versions & operating system are you using?
System:
OS: macOS 15.1
CPU: (8) arm64 Apple M1 Pro
Memory: 104.33 MB / 16.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 24.9.0
npm: 11.6.0
pnpm: 10.11.0
npmPackages:
wrangler: ^4.75.0 => 4.85.0
Please provide a link to a minimal reproduction
https://stackblitz.com/edit/vitejs-vite-gwtpcbsd?file=README.md
Note: wrangler dev is not supported in StackBlitz WebContainers. Clone the repo locally and run npm install && npm run dev to reproduce.
Describe the Bug
wrangler dev truncates deferred chunks of a streaming ReadableStream response. When an outer stream wraps an inner stream and enqueues additional chunks via queueMicrotask after the inner stream ends, most deferred chunks are silently dropped.
Pattern (used by TanStack Router/Start's SSR streaming):
- An inner
ReadableStream sends ~500KB of HTML (simulating React's renderToReadableStream), then closes
- An outer transform stream wraps it, stays open after the inner stream ends
- Deferred data is enqueued via
queueMicrotask with short delays (simulating deferred GraphQL queries resolving — matches TanStack Router's ScriptBuffer)
- A stream end marker is enqueued and the outer stream closes
Expected: All chunks delivered.
Actual: Only 1 of 15 deferred chunks arrives. The stream end marker is missing.
npm run dev
# Should print 15, actually prints 1
curl -s http://localhost:8787/ | grep -c 'deferred-'
# Should print 1, actually prints 0
curl -s http://localhost:8787/ | grep -c 'STREAM_END'
Production Cloudflare Workers are NOT affected — streaming works correctly when deployed. This only affects wrangler dev.
This breaks TanStack Start/Router's defer() SSR streaming, where <script> tags are injected into the response after React's initial render stream completes via transformStreamWithRouter. Components that depend on the streamed deferred data stay in their Suspense fallback indefinitely.
Please provide any relevant error logs
No errors are logged. The chunks are silently dropped — the response simply closes before all chunks are delivered.
Related: #8004, #6577
What versions & operating system are you using?
Please provide a link to a minimal reproduction
https://stackblitz.com/edit/vitejs-vite-gwtpcbsd?file=README.md
Describe the Bug
wrangler devtruncates deferred chunks of a streamingReadableStreamresponse. When an outer stream wraps an inner stream and enqueues additional chunks viaqueueMicrotaskafter the inner stream ends, most deferred chunks are silently dropped.Pattern (used by TanStack Router/Start's SSR streaming):
ReadableStreamsends ~500KB of HTML (simulating React'srenderToReadableStream), then closesqueueMicrotaskwith short delays (simulating deferred GraphQL queries resolving — matches TanStack Router'sScriptBuffer)Expected: All chunks delivered.
Actual: Only 1 of 15 deferred chunks arrives. The stream end marker is missing.
Production Cloudflare Workers are NOT affected — streaming works correctly when deployed. This only affects
wrangler dev.This breaks TanStack Start/Router's
defer()SSR streaming, where<script>tags are injected into the response after React's initial render stream completes viatransformStreamWithRouter. Components that depend on the streamed deferred data stay in their Suspense fallback indefinitely.Please provide any relevant error logs
No errors are logged. The chunks are silently dropped — the response simply closes before all chunks are delivered.
Related: #8004, #6577