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

オープン 初心者向け
#410 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@lafllamme がすでに取り組んでいます。

2026年11月12日 から。

  • #411 @lafllamme による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
78/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
nuxt, typescript

調査の方向性

src/runtime/hydration/composables.tsのhydrationレポート呼び出し箇所と、src/runtime/hydration/handlers.tsのassertPayloadから始めてください。名前のないコンポーネントがどのようにpayloadに渡されるか、拒否されたレポートがどのように処理されるかを追ってください。提示されたtemplateのみの再現例に対してヒントを保存でき、レポートの失敗が未処理エラーにならなければ完了です。issueには実行するテストファイルの指定がありません。

索引モデルが issue の本文から書いたものです。

説明

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)
主要言語
TypeScript
スター
347
フォーク
15
平均マージ
7分
マージ済み PR(30日)
1

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

nuxt/hints のほかの issue

nuxt/hints の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。