[🐞] `send(new Response(stream))` drops its `pipeTo` promise; a failed stream or a client that leaves exits a Bun server

Open Beginner friendly
#9,385 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
75/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
bun, typescript
Domain
backend, web-dev

Research direction

Read packages/qwik-router/src/middleware/request-handler/request-event-core.ts, especially send, and inspect how its pipeTo, write, and close promises are handled. The reproduction in the issue exercises both an errored stream and a client disconnect; use it to check that the server stays alive after both cases.

Written by the indexing model from the issue text.

Description

Which component is affected?

Qwik Router

Describe the bug

send() in the request event starts the write and does not wait for it or handle its failure. With a Response body it calls statusOrResponse.body.pipeTo(writableStream) and drops the returned promise; with a status and a body it drops the writer.write(...) and writer.close() promises the same way (packages/qwik-router/src/middleware/request-handler/request-event-core.ts, send).

When the pipe rejects, nothing handles the rejection. On Bun an unhandled rejection ends the process, so one failed streamed response takes the whole server down:

  1. The body stream errors (for example, an upstream the route is proxying resets its connection): error: <the stream's error>, exit code 1.
  2. The client leaves while the body is still streaming (closed tab, curl --max-time): AbortError: The connection was closed., exit code 1.

Any route that answers with send(new Response(stream)) is exposed (server-sent events, a proxied fetch body). In production this showed up as server processes exiting about a minute after a browser left a live feed.

Reproduced on 2.0.0-rc.4 and still present on main (a96a5fd25a, read 2026-11-06). I only tested Bun 1.4.4.

A one-line change makes both cases survive in the reproduction: handling the rejection of that pipeTo(...) (.catch(() => {}), or routing it to the request's error handling) keeps the server alive. I checked this by editing the built server of the reproduction. The write()/close() promises in the numeric branch need the same treatment.

Reproduction

https://github.com/ixcans/qwik-send-pipe-repro

Steps to reproduce
git clone https://github.com/ixcans/qwik-send-pipe-repro
cd qwik-send-pipe-repro
pnpm install
pnpm build
./check.sh

check.sh starts the built server, makes one request to /stream/?mode=error and one to /stream/?mode=endless (each against a fresh server), and reports whether the server is still alive:

mode=error curl exit=56 http=200  server alive after: NO (exit 1)
mode=endless curl exit=28 http=200  server alive after: NO (exit 1)

The only route is src/routes/stream/index.ts, which calls send(new Response(body)).

System Info
@qwik.dev/router 2.0.0-rc.4
@qwik.dev/core 2.0.0-rc.4
vite 8.3.6
bun 1.4.4 (Linux arm64)
adapter: @qwik.dev/router/adapters/bun-server
Dominant language
TypeScript
Stars
22.1k
Forks
1.4k
Avg merge
2d 17h
Merged PRs (30d)
99

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from QwikDev/qwik

All issues in QwikDev/qwik

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.