[2.0.0] Feature: an app-level default for a mutation that declares no `revalidate` (all | none), and a dev warning when the default fires

オープン
#736 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

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

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
48/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
活発
技術スタック
node.js, typescript

調査の方向性

Start with src/data/query.ts around the sweep logic and trace how responses reach it from setupFlightDataConsumer; then compare the formAction path in src/data/action.ts and router options in src/routing.ts. Decide how an app-level default and dev warning should work consistently across both paths. Done means undeclared revalidation follows the selected default and the diagnostic identifies the server function when the all-query default fires.

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

説明

Describe the bug

Feature request, not a regression. In 2.0.0 a non-GET server-function call made inside a core action() (before its first await, or after a yield), or inside a router formAction, whose answer declares no revalidate, makes the router revalidate every query on screen. That rule is documented and was settled in #4883 / #4913. The only way to say "this changed nothing the page reads" is to write respond(value, { revalidate: [] }) (or "") in every such server function. A function that forgets it gets the sweep silently, and nothing tells the author which function did.

For an app whose server functions are mostly narrow (a cart line, a toggle, a sign-in step) the safe default is the opposite of the built-in one. Every missed declaration costs real work and visible effects:

  • Reads in flight on the page are restarted by the sweep, including the ones a navigation was already waiting on.
  • Reads that a CDN serves from a shared cache are refetched from the origin, because the sweep invalidates the client entry, not just the keys the call touched.
  • An auth flow that ends a session re-reads every query under the session that just ended, so the refetches fail or return signed-out data before the redirect lands.

Where the rule is implemented:

  • @solidjs/web, packages/web/server-functions/src/client.ts L834-L835 (mutation = !isReadCall(options) && sources.length > 0, acted = mutation && actionDepth) and L929-L931: an acted call's response reaches the flight-data consumers even when it carries nothing; documentation/solid-2.0/10-server-functions.md L133 (the 2026-11-16 ruling) describes it, and packages/web/src/response.ts L156 documents the omitted revalidate as "the host's default".
  • @solidjs/router, src/data/query.ts L497 (const sweep = mutation || declared !== null) with keys left undefined (everything) when nothing was declared (L498), reached from setupFlightDataConsumer (L548-L552) for server-function calls and from applyResponse in src/data/action.ts (L640-L647) for formAction.
  • The only switch is createRouter({ singleFlight: false }) (src/routing.ts L1010, README options table), which turns the whole flight-data consumer off rather than changing the default. It also drops folded data and redirects.

There is no dev signal. A call that sweeps everything because nothing was declared looks the same in the console as one that meant it.

Your Example Website or App

No repro app: this is a request for a knob and a diagnostic. The existing behavior is the one in #4883 (the list refetches after a keyless call from an action), seen from the opposite side; for a runnable check of which slice of an action counts as "inside" see the companion issue about calls after the first await.

Steps to Reproduce the Bug or Issue
  1. A query() read for a list and a "use server" function touch() that returns nothing.
  2. Call touch() from a core action() (or a formAction).
  3. The Network panel shows POST /_server/…touch, then a GET for the list. The list read was not related to touch.
  4. To avoid it, touch() must return respond(null, { revalidate: [] }).
Expected behavior

Either (or both) of:

  1. A router option for the default, for example createRouter({ revalidate: 'all' | 'none' }) with 'all' as today's default. With 'none', an answer that declares nothing sweeps nothing and an author opts in per function with revalidate: [...] or "*", which the protocol already has (REVALIDATE_ALL, query.ts L561-L566). It would apply on both paths above (flight-data consumer and formAction), so one setting covers a server function called from an action and from a form.
  2. A dev-only diagnostic, once per function id, when the router applies the "everything" default to an answer that declared nothing, naming the server function (the transport knows the id at the call site) and the fix: [REVALIDATE_UNDECLARED] server function "<id>" answered an action without declaring revalidate; every query on screen was refetched. Declare respond(v, { revalidate: [...] }), { revalidate: [] } for none, or "*" for all. An app that wants the sweep silences it by writing "*".

(2) alone is enough to make the default discoverable; (1) removes the need to touch every function.

Screenshots or Videos

No response

Platform
  • OS: macOS
  • Runtime: Node 26.13.1
  • Version: solid-js / @solidjs/web / @solidjs/router 2.0.0, @solidjs/vite-plugin 3.0.0
主要言語
TypeScript
スター
1.3k
フォーク
193
平均マージ
8時間 48分
マージ済み PR(30日)
21

環境構築

はじめの一歩

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

solidjs/solid-router のほかの issue

solidjs/solid-router の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

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

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