Hydration hint of a component with no name is rejected (400 Invalid payload) and surfaces as an unhandled error

Aperta Adatta ai principianti
#410 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@lafllamme ci sta già lavorando.

Dal 12/11/2026.

  • #411 di @lafllamme — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
78/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
nuxt, typescript

Direzione di ricerca

Inizia in src/runtime/hydration/composables.ts, in corrispondenza della chiamata al report di hydration, e in src/runtime/hydration/handlers.ts, in corrispondenza di assertPayload. Segui come un componente senza nome raggiunge il payload e come viene gestito un report rifiutato. Il lavoro è completato quando l’indicazione può essere memorizzata per la riproduzione fornita, composta solo da un template, e un report non riuscito non diventa un errore non gestito; l’issue non indica alcun file di test da eseguire.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Environment
  • nuxt 4.6.2 (SSR, dev mode)
  • @nuxt/hints 1.1.5 (also checked against main: same code)
  • vue 3.5.44
  • Node.js 26.13.0, Windows 11
Reproduction

A page with no <script setup> (template only), whose HTML differs between server and client, pages/repro.vue:

<template>
  <div>{{ Date.now() }}</div>
</template>

Open /repro in dev mode.

Describe the bug

The hydration hint for that page is never stored, and an unhandled error opens Nuxt's dev error overlay:

FetchError: [POST] "/__nuxt_hints/hydration": 400 Invalid payload

Why it happens (src/runtime/hydration/composables.ts):

  • componentName = instance.type.name ?? instance.type.displayName ?? instance.type.__name. A component with none of the three (a template-only SFC, which gets no __name) sends componentName: undefined. I logged the rejected body: componentName is undefined, fileLocation is the page path, both HTML fields are strings.
  • The server handler rejects it: assertPayload requires typeof body.componentName === 'string' (src/runtime/hydration/handlers.ts).
  • The $fetch(HYDRATION_ROUTE, …).then(…) call has no .catch, so the rejection becomes an unhandled error.

Side effect: the dev error overlay (nuxt-error-overlay) contains a <main>, so accessibility checks run on the page (axe landmark-no-duplicate-main) report two main landmarks.

Expected: the hint is stored and shown in the DevTools panel like the others, and a failed report does not surface as an unhandled error.

Suggestion:

  • fall back to a name derived from __file (e.g. the file's base name) or a placeholder like 'Anonymous' when name, displayName and __name are all missing;
  • and/or add a .catch to the report call that logs a warning instead of throwing.
Additional context

Found while triaging the hydration hints of an app together with #409 (a different false positive in the same check).

Logs
FetchError: [POST] "/__nuxt_hints/hydration": 400 Invalid payload
    at async $fetch2 (.../ofetch/dist/shared/ofetch.CWycOUEr.mjs:332:15)
Lingua principale
TypeScript
Stelle
347
Fork
15
Merge medio
7m
PR unite (30g)
1

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di nuxt/hints

Tutte le issue di nuxt/hints

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.