Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

[2.0 rc.17] A lone spread runs before the element's hydration key on the server, after it on the client

Cerrado
#4,240 0 comentarios 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
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

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

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 solidjs/solid

Todos los issues de solidjs/solid

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.