[🐞] `<Catch>` during SSR: `Cache-Control: no-store` is never sent in a Qwik Router app (the first chunk always leaves before any route component renders)
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 44/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- typescript
Hướng nghiên cứu
Start by reading _walkJSX where the issue says an async component triggers a flush before its promise resolves, then trace the router's onBeforeFirstFlush callback and the in-order streaming options. Add or update an SSR test using a synchronously throwing route component under Catch; done means the response gets Cache-Control: no-store for an error caught before route content is streamed, or the docs clearly describe the limitation and alternative.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Which component is affected?
Qwik Runtime
Describe the bug
Version: @qwik.dev/core / @qwik.dev/router 2.0.0-rc.3, and main at e63f0b2 (pkg.pr.new build). experimental: ["catchBoundary", "pendingBoundary", "blockSSR"].
What happens
The Catch docs (Caching) say:
An error caught during SSR still responds 200, so the framework refuses to let that response be
cached: it sendsCache-Control: no-storewhen the error precedes the first chunk […]
In a Qwik Router app this never happens, even when a route component throws synchronously on its
first render. The response is 200 with no Cache-Control header. The router's
onBeforeFirstFlush callback, which sets no-store, always gets { hasCaughtError: false }.
The cause: in _walkJSX, when a component$ body returns a promise, the walker flushes the buffer
before awaiting it (await ssr.streamHandler.flush(), "Defer reading QScopedStyle until after the
promise resolves"). The root component (useQwikRouter()) has an async body, so the first flush
happens right after <html …> is written (209 bytes in the repro), before <head>, the layout or
the route. That flush is the first write, so onBeforeFirstFlush runs there and the response
headers leave. It happens with every in-order strategy: auto with a large
maximumInitialChunk and disabled give the same result.
Minimal reproduction
import { $, Catch, component$ } from "@qwik.dev/core";
/** Throws while rendering on the server. */
const Broken = component$(() => {
throw new Error("E-MARKER: render failed");
});
export default component$(() => (
<Catch fallback$={$((error) => <p id="fallback">fallback: {error.message}</p>)}>
<Broken />
</Catch>
));
GET /e/ → HTTP 200, no Cache-Control header, fallback rendered
Expected per the docs: Cache-Control: no-store, since nothing of the route was streamed before
the error.
Things that don't change the result (rc.3 and main e63f0b2, dev and production build):
streaming: { outOfOrder: false };streaming: { inOrder: { strategy: "auto", maximumInitialChunk: 100000 } };streaming: { inOrder: { strategy: "disabled" } };- a
renderToStreamonBeforeFirstFlushthat wraps the router's: it is called once, with
{"hasCaughtError":false}; getRequestEvent().headersSentinside the boundary'sonError$is alreadytrue, so the app
can't set a status there either.
The SSR cache part works (result.hasCaughtError is read after the render). Only the header part,
and anything else that relies on onBeforeFirstFlush's hasCaughtError, is unreachable.
Expected
One of:
- the first flush waits until something of the app body is ready (or at least respects the in-order
strategy, sodisabled/maximumInitialChunkcan hold it back), so an early caught error can
still setno-store(and a status, from an app hook); - or, if flushing
<html>early is intended, the docs say thatno-storeis only possible without
an async root, and point to the alternative (error responses from loaders / request handlers,
as #8913 plans to document).
Related
- #8745 added the SSR
Catchwithno-store; #8913 (open) is the docs follow-up about caching.
Reproduction
https://github.com/Pancio-code/qwik2-rc3-repros
Steps to reproduce
git clone https://github.com/Pancio-code/qwik2-rc3-repros
cd qwik2-rc3-repros && npm install
npm run build.client && npm run build.preview
node verify-e.mjs
E_STATUS=1 E_INORDER=disabled node verify-e.mjs /e/
src/entry.ssr.tsx reads the flags: E_STATUS=1 wraps onBeforeFirstFlush (logs info, and on
hasCaughtError sets 500), E_CHUNK=n sets maximumInitialChunk, E_INORDER=disabled, OOS=0.
E_APP=1 makes the boundary's onError$ log headersSent. Output on rc.3 (build):
build
/e/ HTTP 200, cache-control=null, fallback="fallback: An error occurred"
server: (nothing)
/e-late/ HTTP 200, cache-control=null, fallback="fallback: An error occurred"
server: (nothing)
build E_STATUS=1 E_CHUNK=100000
/e/ HTTP 200, cache-control=null, fallback="fallback: An error occurred"
server: [E] onBeforeFirstFlush {"hasCaughtError":false}
build OOS=0 E_STATUS=1 E_INORDER=disabled
/e/ HTTP 200, cache-control=null, fallback="fallback: An error occurred"
server: [E] onBeforeFirstFlush {"hasCaughtError":false}
build E_APP=1
/e/ HTTP 200, cache-control=null, fallback="fallback: An error occurred"
server: [onError$] headersSent=true
System Info
System:
OS: Linux 7.0 Ubuntu 26.04.1 LTS 26.04.1 LTS (Resolute Raccoon)
CPU: (32) x64 Intel(R) Core(TM) i9-14900HX
Container: Yes
Shell: 5.3.9 - /bin/bash
Binaries:
Node: 24.21.0 - /home/pancio_o/.nvm/versions/node/v24.21.0/bin/node
npm: 11.19.0 - /home/pancio_o/.nvm/versions/node/v24.21.0/bin/npm
Browsers:
Firefox: 158.0
Firefox Developer Edition: 158.0
npmPackages:
@qwik.dev/core: 2.0.0-rc.3 => 2.0.0-rc.3
@qwik.dev/router: 2.0.0-rc.3 => 2.0.0-rc.3
typescript: 5.9.3 => 5.9.3
vite: 8.2.1 => 8.2.1
Additional Information
Found in a production app moving to 2.0.0-rc.3: we wanted page-level SSR errors to answer 5xx and
saw that neither no-store nor a status set from onError$ ever reaches the response. The 200
itself and the silence in the server logs are documented (report through onError$), so we don't
ask to change those.
- Ngôn ngữ chính
- TypeScript
- Star
- 22.1k
- Fork
- 1.4k
- Merge trung bình
- 1 ngày 13 giờ
- Pull request đã merge (30 ngày)
- 159
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Có Dockerfile hoặc tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của QwikDev/qwik
-
Reveal: resolved but blocked Pending boundary hides its fallbackCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
docs router V2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
DX enhancement V2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
QwikDev/qwik#8480 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
Maintainer thường phản hồi trong vòng 1 ngày
-
preloader V2
Độ khó 4/5 1-2 ngày Mức phù hợp với người mới 58/100
Maintainer thường phản hồi trong vòng 1 ngày
Issue tương tự
-
type: bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
db-ux-design-system/core-web#8856 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
'!' breaking change is lost when the commit also has an empty BREAKING CHANGE footerCó thể đã có người làm @wittdennis đã nhận hôm nay. Đang mởpriority: p3 type: bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
googleapis/release-please#2971 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 87/100
Maintainer thường phản hồi trong vòng 1 ngày
-
🛠️ dette technique
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 61/100
betagouv/mon-entreprise#4752 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 5 ngày