[🐞] Navigating away while a route loader is still loading leaves `.value` as the internal NEEDS_COMPUTATION symbol; components of the old page re-render and crash

Đang mở
#9,237 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

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
48/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ệ
javascript, playwright, typescript, vite

Hướng nghiên cứu

Start with startNavigation, abortRouteLoaderNavigation, and the async computed $setError$ and untrackedValue paths described in the issue; compare the behavior for aborted and disposed loader signals. Reproduce with the provided /g/b/ and /g/c/ routes, then run npm run verify in the linked reproduction. Done means an aborted read suspends or throws instead of returning the internal symbol, and navigating to /g/c/ completes without the old page crashing.

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: 2.0.0-rc.3, experimental: ["catchBoundary", "pendingBoundary", "blockSSR"].

Route /g/b/ has a blockSSR: false loader that takes 1 s, read by a component inside <Pending>. Click a
link to /g/b/, then, before the loader resolves, click a link to /g/c/. The component of /g/b/ re-renders
once more and useData().value is Symbol(qwik.2.0.0-rc.3….invalid):

Data render, value: Symbol(qwik.2.0.0-rc.3-dev+3fd543f.invalid)
QWIK ERROR Cannot read properties of undefined (reading 'toLocaleString')

Every timing we tried (100, 300, 600 ms after reaching /g/b/) reproduces it. If an app has a <Catch>
around <RouterOutlet> (the v2 replacement for useErrorBoundary), the error replaces the whole app and
the navigation to /g/c/ never completes.

Minimal reproduction

Plain [email protected] empty starter with the three experimental flags in qwikVite; /g/ links to /g/b/ and /g/c/ (static). src/routes/g/b/index.tsx:

import { component$, Pending } from "@qwik.dev/core";
import { Link, routeLoader$ } from "@qwik.dev/router";

export const useData = routeLoader$(
  async () => {
    await new Promise((r) => setTimeout(r, 1000));
    return { count: 3 };
  },
  { blockSSR: false },
);

const Data = component$(() => {
  const data = useData();
  // After an aborted navigation `data.value` is the internal NEEDS_COMPUTATION symbol.
  console.log("Data render, value:", String(data.value));
  return <p id="data">{data.value.count.toLocaleString()}</p>;
});

export default component$(() => (
  <main>
    <h1>B</h1>
    <Link id="go-c" href="/g/c/">C</Link>
    <Pending fallback$={() => <p>loading…</p>}>
      <Data />
    </Pending>
  </main>
));

Build, vite preview, open /g/, click B, then within 1 s click C.

Where
  • startNavigation: if (wasNavigating) abortRouteLoaderNavigation(routeLoaderCtx) calls signal.abort()
    on the loaders of the navigation still in progress.
  • Async computed $setError$: on AbortError it returns early without resetting anything, so a signal whose
    first computation was aborted has no promise, no error and $untrackedValue$ === NEEDS_COMPUTATION; the
    untrackedValue getter then returns the symbol instead of throwing the promise or recomputing.
Expected

Reading .value after an abort either suspends (recomputes) or throws, but never returns the internal
symbol; and components of the page being left are not re-rendered by the abort.

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
npx vite preview

Open /g/ (source: src/routes/g/). npm run verify runs the same case headless with Playwright and prints the result (see the README).

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
    Chromium (Playwright 1.64.1, used by `npm run verify`)
  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 while moving a production app to 2.0.0-rc.3. With a <Catch> around <RouterOutlet> the error replaced the whole app. We carry a local patch in the ComputedSignalImpl untrackedValue getter (an aborted computation is marked invalid so the read recomputes and suspends; a disposed one suspends forever) and can open a PR if the approach is welcome. The same happens to a loader signal disposed by pruneRouteLoaders while a component of the old page renders once more. Related: #9236 (same app, different bug).

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

Mở trong Codespaces

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.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của QwikDev/qwik

Tất cả issue của QwikDev/qwik

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.