Skip to content

fix(router): honor SSR backpressure via drain event for compression compatibility#8620

Merged
wmertens merged 1 commit intobuild/v2from
v2-fix-node-streaming-compression
May 10, 2026
Merged

fix(router): honor SSR backpressure via drain event for compression compatibility#8620
wmertens merged 1 commit intobuild/v2from
v2-fix-node-streaming-compression

Conversation

@maiieul
Copy link
Copy Markdown
Member

@maiieul maiieul commented May 10, 2026

What is it?

  • Bug

Description

Since #8557 the Node SSR adapter resolves each chunk's write promise through res.write's per-chunk callback. compression (and similar wrappers) replace res.write with a 2-arg signature (chunk, encoding) and drop that callback, hanging streaming SSR mid-response.

Switch to Node's standard backpressure protocol — return value + 'drain' event — and resolve close() on 'finish', calling res.end() without a callback so compression@1.x's 2-arg res.end doesn't blow up on Buffer.from(<callback>).

Pre-#8557 #8557 This PR
Pause when buffer full? ❌ never ✅ via per-write callback ✅ via 'drain' event
Robust to wrappers like compression? (didn't matter — never paused) ❌ hangs if callback dropped ✅ — 'drain' / return value is the universal contract

Reproduced and verified end-to-end against a real Express + compression app.

@maiieul maiieul requested a review from a team as a code owner May 10, 2026 19:21
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 10, 2026

🦋 Changeset detected

Latest commit: 5d2fe55

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

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

@maiieul maiieul self-assigned this May 10, 2026
@maiieul maiieul moved this to Waiting For Review in Qwik Development May 10, 2026
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 10, 2026

Open in StackBlitz

@qwik.dev/core

npm i https://pkg.pr.new/QwikDev/qwik/@qwik.dev/core@8620

@qwik.dev/router

npm i https://pkg.pr.new/QwikDev/qwik/@qwik.dev/router@8620

eslint-plugin-qwik

npm i https://pkg.pr.new/QwikDev/qwik/eslint-plugin-qwik@8620

create-qwik

npm i https://pkg.pr.new/QwikDev/qwik/create-qwik@8620

@qwik.dev/optimizer

npm i https://pkg.pr.new/QwikDev/qwik/@qwik.dev/optimizer@8620

commit: 5d2fe55

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 10, 2026

built with Refined Cloudflare Pages Action

⚡ Cloudflare Pages Deployment

Name Status Preview Last Commit
qwik-docs ✅ Ready (View Log) Visit Preview 5d2fe55

Copy link
Copy Markdown
Member

@wmertens wmertens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 🧑‍🌾

@wmertens wmertens merged commit 8994d30 into build/v2 May 10, 2026
32 checks passed
@wmertens wmertens deleted the v2-fix-node-streaming-compression branch May 10, 2026 20:18
@github-project-automation github-project-automation Bot moved this from Waiting For Review to Done in Qwik Development May 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants