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

Abierto
#9,237 1 comentario 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
48/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
javascript, playwright, typescript, vite

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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

Lenguaje dominante
TypeScript
Estrellas
22.1k
Forks
1.4k
Merge medio
1 d 13 h
PR fusionados (30 d)
159

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de QwikDev/qwik

Todos los issues de QwikDev/qwik

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.