[🐞] `send(new Response(stream))` drops its `pipeTo` promise; a failed stream or a client that leaves exits a Bun server
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
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:
- The body stream errors (for example, an upstream the route is proxying resets its connection):
error: <the stream's error>, exit code 1. - 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
Starts the project's dev container in your browser, under your own GitHub account.
- Ships a Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from QwikDev/qwik
-
[🐞] SSG: "Qwik Router SSG was skipped" warning on every SSG build, while pages are prerenderedPossibly taken @itsnjstyle27 claimed this 2 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
docs router V2
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
DX enhancement V2
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
QwikDev/qwik#8480 · 2 comments ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 52/100
Maintainers usually reply within 1 day
-
[🐞] A layout's loader request runs the loaders of the page at the layout's path as guards: a redirect there bounces client navigations in productionPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 4/5 3-5 days Newbie friendliness 46/100
Maintainers usually reply within 1 day
Similar issues
-
area:frontend kind:bug priority:p2 ready
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
handsontable/hyperformula#1879 ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
RunestoneInteractive/rs#1661 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
capricorn86/happy-dom#2594 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day