[PR #879] [codex] Fix wrangler dev suspense streaming #917

Open
opened 2026-05-06 13:10:50 +02:00 by BreizhHardware · 0 comments

📋 Pull Request Information

Original PR: https://github.com/cloudflare/vinext/pull/879
Author: @southpolesteve
Created: 4/24/2026
Status: 🔄 Open

Base: mainHead: codex/fix-wrangler-suspense-streaming


📝 Commits (1)

  • b08ce9a fix wrangler dev suspense streaming

📊 Changes

8 files changed (+397 additions, -52 deletions)

View changed files

📝 packages/vinext/src/entries/app-rsc-entry.ts (+3 -23)
📝 packages/vinext/src/server/app-router-entry.ts (+2 -2)
📝 packages/vinext/src/server/app-ssr-stream.ts (+40 -27)
packages/vinext/src/server/flight-hints.ts (+134 -0)
📝 packages/vinext/src/server/worker-utils.ts (+36 -0)
📝 tests/app-ssr-stream.test.ts (+77 -0)
📝 tests/deploy.test.ts (+55 -0)
📝 tests/rsc-streaming.test.ts (+50 -0)

📄 Description

Summary

  • Add a local Wrangler dev response wrapper that sets Content-Encoding: identity for streamed loopback App Router responses without explicit body headers.
  • Replace whole-line RSC Flight hint buffering with a streaming transform so partial non-hint rows can flow immediately.
  • Keep the SSR HTML/RSC embed flush independent of host timers while preserving tick-level batching.

Root Cause

wrangler dev/Miniflare buffers streamed non-SSE responses unless compression is explicitly avoided. The behavior reproduces with a plain ReadableStream route, outside React and vinext rendering. Setting Content-Encoding: identity restores chunk delivery locally.

This aligns with upstream Cloudflare workers-sdk issue #8004, which describes Miniflare aggressively buffering responses and lists Content-Encoding: identity as the workaround.

Validation

  • npx vp test run tests/app-ssr-stream.test.ts tests/rsc-streaming.test.ts tests/deploy.test.ts -t "applyLocalDevStreamingHeaders|host timers|createFlightHintFixTransform"
  • npx vp check packages/vinext/src/server/worker-utils.ts packages/vinext/src/server/app-router-entry.ts packages/vinext/src/server/app-ssr-stream.ts packages/vinext/src/server/flight-hints.ts packages/vinext/src/entries/app-rsc-entry.ts tests/app-ssr-stream.test.ts tests/rsc-streaming.test.ts tests/deploy.test.ts
  • npx vp run vinext#build
  • Manual Wrangler repro: before the workaround /streaming buffered until ~830ms; after the workaround the fallback arrived at ~47ms and resolved content at ~834ms.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/cloudflare/vinext/pull/879 **Author:** [@southpolesteve](https://github.com/southpolesteve) **Created:** 4/24/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `codex/fix-wrangler-suspense-streaming` --- ### 📝 Commits (1) - [`b08ce9a`](https://github.com/cloudflare/vinext/commit/b08ce9a05e154cb1cfd6eb99e268f22a8a607ad5) fix wrangler dev suspense streaming ### 📊 Changes **8 files changed** (+397 additions, -52 deletions) <details> <summary>View changed files</summary> 📝 `packages/vinext/src/entries/app-rsc-entry.ts` (+3 -23) 📝 `packages/vinext/src/server/app-router-entry.ts` (+2 -2) 📝 `packages/vinext/src/server/app-ssr-stream.ts` (+40 -27) ➕ `packages/vinext/src/server/flight-hints.ts` (+134 -0) 📝 `packages/vinext/src/server/worker-utils.ts` (+36 -0) 📝 `tests/app-ssr-stream.test.ts` (+77 -0) 📝 `tests/deploy.test.ts` (+55 -0) 📝 `tests/rsc-streaming.test.ts` (+50 -0) </details> ### 📄 Description ## Summary - Add a local Wrangler dev response wrapper that sets `Content-Encoding: identity` for streamed loopback App Router responses without explicit body headers. - Replace whole-line RSC Flight hint buffering with a streaming transform so partial non-hint rows can flow immediately. - Keep the SSR HTML/RSC embed flush independent of host timers while preserving tick-level batching. ## Root Cause `wrangler dev`/Miniflare buffers streamed non-SSE responses unless compression is explicitly avoided. The behavior reproduces with a plain `ReadableStream` route, outside React and vinext rendering. Setting `Content-Encoding: identity` restores chunk delivery locally. This aligns with upstream Cloudflare workers-sdk issue #8004, which describes Miniflare aggressively buffering responses and lists `Content-Encoding: identity` as the workaround. ## Validation - `npx vp test run tests/app-ssr-stream.test.ts tests/rsc-streaming.test.ts tests/deploy.test.ts -t "applyLocalDevStreamingHeaders|host timers|createFlightHintFixTransform"` - `npx vp check packages/vinext/src/server/worker-utils.ts packages/vinext/src/server/app-router-entry.ts packages/vinext/src/server/app-ssr-stream.ts packages/vinext/src/server/flight-hints.ts packages/vinext/src/entries/app-rsc-entry.ts tests/app-ssr-stream.test.ts tests/rsc-streaming.test.ts tests/deploy.test.ts` - `npx vp run vinext#build` - Manual Wrangler repro: before the workaround `/streaming` buffered until ~830ms; after the workaround the fallback arrived at ~47ms and resolved content at ~834ms. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/vinext#917
No description provided.