[2.0 rc.15 / next] GRAPH_GROWTH reports a keyed cache filling with new keys as a leak, and a cache has no way to say what it is
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
- 15/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Activo
- Stack tecnológico
- typescript
- Área
- frontend, observability
Línea de trabajo
Start with walkGraph in packages/signals/src/core/attribution.ts, which counts nodes alive at both navigation start and settle as survived, and with createProjection next to createStore, which records owners in storeOwners but does not. Run the three-variant repro from the issue under --conditions=browser --conditions=development. Done means variant B goes quiet, variants A and C still report, and the three new graph-growth tests pass. The { cache: true } option is a design proposal, so confirm the API with maintainers before implementing.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Summary
A cache that keeps entries by key reports GRAPH_GROWTH when visits fill it with new keys, and the message says a visit left a createRoot() behind with no dispose. This is the usual shape of a data layer's entity cache: one entry per item, each under its own root so it can be evicted, all under the cache's long-lived root. Since #4020 (fixing #4007), a series must also climb in what outlived each navigation, but a cache's entries are alive when the next navigation starts and survive it, exactly as a leaked root would. Nothing in the graph's shape tells a cache filling up from a leak, and there is no way for the cache to say what it is. OBSERVE.exclude is meant for an observer's own subtree and silences every diagnostic under it, not only this check.
Reproduction
solid-js 2.0.0-rc.15, no DOM. Each visit to /items/:page lists two items the cache hasn't seen; / sits between visits.
import {
OBSERVE,
createEffect,
createMemo,
createProjection,
createRenderEffect,
createRoot,
createSignal,
flush,
getOwner,
runWithOwner,
} from "solid-js";
import { attribution } from "solid-js/attribution";
const variant = process.argv[2] ?? "A";
attribution.enable({ log: false });
const findings: { route: string; grew: string[] }[] = [];
OBSERVE!.diagnostics.subscribe((event) => {
if (event.code === "GRAPH_GROWTH") findings.push(event.data as { route: string; grew: string[] });
});
// An entry per item (a signal and a projection of it), each under its own
// root so it can be evicted, all under the cache's root.
const cache = createRoot((dispose) => ({ owner: getOwner()!, dispose }), {
cache: variant !== "A",
});
const entries = new Map<number, { value: number }>();
const fill = (id: number) =>
runWithOwner(cache.owner, () =>
createRoot(() => {
const [value] = createSignal(id);
entries.set(
id,
createProjection<{ value: number }>(
(draft) => {
draft.value = value() * 2;
},
{ value: 0 },
),
);
}),
);
const leaked: (() => void)[] = [];
const app = createRoot((dispose) => {
const [location, setLocation] = createSignal("/");
createRenderEffect(
() => (location(), [...entries.values()].reduce((sum, entry) => sum + entry.value, 0)),
() => {},
);
return { setLocation, dispose };
});
flush();
const navigate = (name: string, to: string, before?: () => void) => {
OBSERVE!.attribution.withOrigin({ kind: "navigation", name, to }, () => {
before?.();
app.setLocation(to);
});
flush();
};
for (const page of [1, 2, 3]) {
navigate("/items/:page", `/items/${page}`, () => {
fill(page * 2 - 1);
fill(page * 2);
if (variant === "C")
runWithOwner(null, () =>
createRoot((dispose) => {
leaked.push(dispose);
const [n] = createSignal(0);
createEffect(n, () => {});
createMemo(() => n() + 1);
}),
);
});
navigate("/", "/");
}
console.log(variant, findings);
Run with node --conditions=browser --conditions=development repro.ts <A|B|C>.
| Variant | 2.0.0-rc.15 | 2.0.0-rc.15 with the fix below |
|---|---|---|
| A: the cache under a plain root | reports | reports |
B: the cache root created with { cache: true } |
reports | quiet |
| C: B, plus a detached root left behind on every visit | reports | reports |
Without the fix the option doesn't exist, so B is the same as A.
Cause
walkGraph (packages/signals/src/core/attribution.ts) counts every node alive at a navigation's start and still alive at its settle as survived, whoever owns it. Projections also record no owner: createStore puts its owner in storeOwners, and store property nodes are stamped from it, but createProjection doesn't, so a projection's property nodes have none.
Expected
A cache can declare itself, and what it keeps is left out of what survived, while a leak beside it still reports. Related: #4007, #4020.
Possible fix
Let a root say it is a cache: createRoot(fn, { cache: true }) (and createOwner). Observe tiers set a config bit for it, as they do for CONFIG_WIDE and CONFIG_SUPERSEDES, and prod ignores the option. walkGraph then leaves out of survived what such a root keeps: the owners and computations under it, and the signals created there (_owner). The whole-graph counts (graphSize()) are unchanged. createProjection records the owner in scope in storeOwners, as createStore does, so the stores and projections a cache keeps are left out too, and their attribution owner paths become complete as well.
Tested on the RC.15 release commit (ea4438b1; next at 9f4174b6 has no signals changes since): the signals suite passes with it (5,212 tests, 20 expected failures, 2 skipped; 5,209 without it). Three new graph-growth tests cover a declared cache staying quiet, the same cache undeclared still reporting, and a leak beside a declared cache still reporting. The two declared-cache tests fail without the change, and the first one also fails when only the projection's owner isn't recorded.
(submitted by Claude Opus 5.5 on behalf of rvlzzr)
- Lenguaje dominante
- TypeScript
- Estrellas
- 36.1k
- Forks
- 1.1k
- Merge medio
- 11 h 32 min
- PR fusionados (30 d)
- 356
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de solidjs/solid
-
[2.0 / next] Error formatting and async iterator protocol failures escape memo error handlingAbierto
Dificultad 4/5 3-5 días Aptitud para principiantes 22/100
Los mantenedores suelen responder en 1 día
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 14/100
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 3-5 días Aptitud para principiantes 18/100
Los mantenedores suelen responder en 1 día
-
[2.0 / next] Outside latest reads of a derivation expose errors and values at different timesAbierto
Dificultad 4/5 3-5 días Aptitud para principiantes 22/100
Los mantenedores suelen responder en 1 día
Todos los issues de solidjs/solid
Issues similares
-
documentation good first issue
Dificultad 2/5 Medio día Aptitud para principiantes 72/100
sujithputta02/Esapay#13 ·
-
Share dialog: the address book's contact count reads "1 contacts" (no singular form in any language)Posiblemente ocupada @chibenwa la tomó hoy. Abiertoai-driven-qa bug claude Cosmetic
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
linagora/twake-contacts-frontend#271 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Koenkk/zigbee2mqtt#33402 ·
Los mantenedores suelen responder en 1 día
-
dx P2 platform Stellar Wave Wave 10
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
winsznx/routedock#579 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
area:ui effort:S enhancement priority:P2
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día