[🐞] 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

オープン
#9,237 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
48/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
javascript, playwright, typescript, vite

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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).

主要言語
TypeScript
スター
22.1k
フォーク
1.4k
平均マージ
1日 13時間
マージ済み PR(30日)
159

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

QwikDev/qwik のほかの issue

QwikDev/qwik の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。