[2.0 rc.17] A lone spread runs before the element's hydration key on the server, after it on the client
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 58/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- javascript, typescript
- Área
- frontend, full-stack
Línea de trabajo
Start by tracing how the compiler emits server output for a JSX element with a lone spread, then compare it with the client output described in the issue. Check the ssrElement hydration-key allocation and the existing spread compilation tests. Done when a lone spread runs after the server element's hydration key and the reported hydration mismatch is covered by a regression test.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Describe the bug
Take an element whose only attribute is a spread: <label {...props()} />. The server compiles it to ssrElement(tag, props(), children, true), so props() is an argument and runs before ssrElement allocates the element's hydration key. The client compiles the same element to getNextElement(tmpl) and then spread(el, () => props()), so it claims the key first and runs props() afterwards.
If props() creates an owner (a memo, for example), the server gives that owner the id the element should get. The element's key then shifts by one, on the server only. The client misses the key, creates a detached element, and leaves the server node unclaimed and inert.
When the element has any other attribute, the server wraps the spread in a thunk (ssrElement(tag, [{...}, () => props()], ...)), runs it after the key, and the two sides agree.
Compiled output (@solidjs/vite-plugin 3.0.0-next.51, { ssr: true }):
// server: <label {...composeProps(row, () => ({ class: "x" }))} />
(row) => ssrElement("label", composeProps(row, () => ({ class: "x" })), undefined, true)
// client
var _el$ = _$getNextElement(_tmpl$);
_$spread(_el$, () => composeProps(row, () => ({ class: "x" })), false, undefined, "label")
ssrElement takes the key inside the call (const hk = needsId ? ssrHydrationKey() : ""), after its arguments have been evaluated.
Your Example Website or App
Minimal repro below (no libraries).
Steps to Reproduce the Bug or Issue
// app.tsx: server-render with renderToString + generateHydrationScript, then hydrate(() => <App />, root)
import { createMemo, Show } from "solid-js";
// Creates an owner (a memo) while computing the spread.
const withMemo = () => {
const title = createMemo(() => "spread");
return { get title() { return title(); } };
};
export function App() {
return (
<main>
<Show when={true}>
<label {...withMemo()}>lone spread</label>
</Show>
<Show when={true}>
<label data-x="" {...withMemo()}>spread plus attribute</label>
</Show>
</main>
);
}
Console on hydrate (dev):
Hydration key miss for "30": no server-rendered element carries this key (template: <label>lone spread). A detached element was created instead; ...
Hydration completed with 1 unclaimed server-rendered node(s):
<label _hk="31" title="spread">lone spread</label>
The second label (spread plus an attribute) hydrates.
Expected behavior
A lone spread is evaluated after the element's hydration key on the server, as it is on the client and as a spread next to other attributes already is. For example, emit ssrElement(tag, () => props(), ...), or take the key before evaluating the props.
Platform
- solid-js / @solidjs/web 2.0.0-rc.17
- @solidjs/vite-plugin 3.0.0-next.51 (@solidjs/compiler, @solidjs/babel-plugin 2.0.0-rc.17)
- Chromium (Playwright), Node 26
Additional context
We hit this in a component library, where a styled Switch renders <label {...composeProps(row, () => attrs)} /> and each accessor source becomes a memo. We worked around it by making those memos transparent: true. Related but different: #4081 (ref dropped on a spread element).
- Lenguaje dominante
- TypeScript
- Estrellas
- 36.2k
- Forks
- 1.1k
- Merge medio
- 11 h
- PR fusionados (30 d)
- 343
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
-
`lazy()`: remounting an already-loaded component renders empty (or the Suspense fallback) since 1.9.14Posiblemente ocupada @itisrmk la tomó hace 8 días. Abierto1.x
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 3-5 días Aptitud para principiantes 56/100
Los mantenedores suelen responder en 1 día
-
enhancement
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
Los mantenedores suelen responder en 1 día
-
`createRoot`'s dispose function keeps `fn` alive, so `<For>`/`<Index>` rows retain removed list itemsPosiblemente ocupada @boombang la tomó hace 10 días. Abierto1.x
Dificultad 4/5 1-2 días Aptitud para principiantes 45/100
Los mantenedores suelen responder en 1 día
-
Keep element state when the runtime moves a node (`moveBefore()` and not detaching what is re-inserted)Posiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abiertoenhancement
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
Los mantenedores suelen responder en 1 día
Todos los issues de solidjs/solid
Issues similares
-
VS Code extension: clickable file links in chat drop the :line suffix, never jump to the lineAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
MoonshotAI/kimi-code#4398 ·
Los mantenedores suelen responder en 1 día
-
Xiaomi Mimo语音识别服务异常Abiertopending triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
Los mantenedores suelen responder en 1 día
-
package-lock.json : les binaires natifs macOS et Linux de unrs-resolver ont disparu depuis #1823Abiertobug dependencies
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
AxaFrance/design-system#2064 ·
Los mantenedores suelen responder en 3 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100