From aab56deb39701fc103f7430078a6f5ac86449504 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 18 Nov 2026 11:07:41 +0000 Subject: [PATCH 1/8] fix(release): skip already-published packages in artifact verification Since #4985, h, html and element version on their own, so a core release leaves them at a version already on npm. verify-release-artifacts.mjs dry-run-published every public package, and npm refuses even a dry run over a published version, so the 2.0.1 release failed before publishing anything. It now skips a published version the same way release.mjs does, with packageIsPublished shared from release-packages.mjs. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_0117BoWMR7ndYUnqBW5NjTbC --- scripts/release-packages.mjs | 14 ++++++++++++++ scripts/release.mjs | 12 +----------- scripts/verify-release-artifacts.mjs | 10 ++++++++-- 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/scripts/release-packages.mjs b/scripts/release-packages.mjs index 228dd5e06..756d6fcc6 100644 --- a/scripts/release-packages.mjs +++ b/scripts/release-packages.mjs @@ -3,6 +3,7 @@ // the core runtime is a fixed group, the compilers are linked, and h, html // and element version on their own), so each package carries its own // version and dist-tag. +import { spawnSync } from "node:child_process"; import fs from "node:fs"; // A prerelease version (2.1.0-rc.N) publishes to the `next` channel; a @@ -11,6 +12,19 @@ export function distTagFor(version) { return version.includes("-") ? "next" : "latest"; } +// Whether `name@version` is already on npm. A package whose version did not +// move this release (h, html and element version on their own) is already +// published, and npm refuses to publish over it, even in a dry run. +export function packageIsPublished(name, version) { + return ( + spawnSync("npm", ["view", `${name}@${version}`, "version"], { + cwd: process.cwd(), + env: process.env, + stdio: "ignore" + }).status === 0 + ); +} + export function releasePackages(root = ".") { const packages = new Map(); for (const entry of fs.readdirSync(`${root}/packages`, { withFileTypes: true })) { diff --git a/scripts/release.mjs b/scripts/release.mjs index 20489b7c5..68378932c 100644 --- a/scripts/release.mjs +++ b/scripts/release.mjs @@ -1,6 +1,6 @@ import { execFileSync, spawnSync } from "node:child_process"; import fs from "node:fs"; -import { distTagFor, releasePackages } from "./release-packages.mjs"; +import { distTagFor, packageIsPublished, releasePackages } from "./release-packages.mjs"; const repository = process.env.GITHUB_REPOSITORY; const branch = process.env.GITHUB_REF_NAME; @@ -31,16 +31,6 @@ function output(command, args) { }).trim(); } -function packageIsPublished(name, version) { - return ( - spawnSync("npm", ["view", `${name}@${version}`, "version"], { - cwd: process.cwd(), - env: process.env, - stdio: "ignore" - }).status === 0 - ); -} - function remoteTagExists(tag) { return ( spawnSync("git", ["ls-remote", "--exit-code", "--tags", "origin", `refs/tags/${tag}`], { diff --git a/scripts/verify-release-artifacts.mjs b/scripts/verify-release-artifacts.mjs index b28d8905e..2565231ce 100644 --- a/scripts/verify-release-artifacts.mjs +++ b/scripts/verify-release-artifacts.mjs @@ -1,12 +1,14 @@ // Dry-run-publishes every release package and asserts the tarball would // contain the manifest's entry points (main/module/types/browser/bin/exports). // Catches broken `files` globs, missing dist output, and manifest mistakes -// BEFORE release.mjs publishes anything. Requires a completed build +// BEFORE release.mjs publishes anything. A package whose version is already +// on npm is skipped, as release.mjs skips it: npm refuses even a dry run +// over a published version. Requires a completed build // (`pnpm run build && pnpm run types`); runs npm with --ignore-scripts so // prepublish hooks do not re-build. import { execFileSync } from "node:child_process"; import fs from "node:fs"; -import { releasePackages } from "./release-packages.mjs"; +import { packageIsPublished, releasePackages } from "./release-packages.mjs"; const directories = releasePackages(); @@ -35,6 +37,10 @@ function collectEntryFiles(pkg) { const failures = []; for (const [name, { directory, pkg }] of directories) { + if (packageIsPublished(name, pkg.version)) { + console.log(`${name}@${pkg.version} is already published; skipping.`); + continue; + } let report; try { const stdout = execFileSync( From 21b45b704fbaad507e12c7f72efea9bb34057eaf Mon Sep 17 00:00:00 2001 From: gnovotny Date: Wed, 18 Nov 2026 17:18:17 +0100 Subject: [PATCH 2/8] fix(signals): a reader linked to a settled source no longer stays pending on it retryReaches counted a dep that is the source itself as a path even after that source settled, so settleFamily and the re-park sweep in recompute kept a settled derive node in a reader's pending sources. With an optimistic store over one async memo and a slower sibling memo whose re-ask answers unchanged, the reader stayed pending and the action's transaction never landed. A direct link now counts only while the source is pending. Claude-Session: https://claude.ai/code/session_01CP9T3j2CTCEPyTS2bcKsBu --- .changeset/settled-source-holds-nothing.md | 5 + packages/signals/docs/RULES-INDEX.md | 4 +- packages/signals/src/core/async.ts | 5 +- ...tore-derive-settled-before-sibling.test.ts | 103 ++++++++++++++++++ 4 files changed, 113 insertions(+), 4 deletions(-) create mode 100644 .changeset/settled-source-holds-nothing.md create mode 100644 packages/signals/tests/optimistic-store-derive-settled-before-sibling.test.ts diff --git a/.changeset/settled-source-holds-nothing.md b/.changeset/settled-source-holds-nothing.md new file mode 100644 index 000000000..02812c20d --- /dev/null +++ b/.changeset/settled-source-holds-nothing.md @@ -0,0 +1,5 @@ +--- +"@solidjs/signals": patch +--- + +fix(signals): a reader linked to a settled source no longer stays pending on it, so an action whose reader waits on a derived optimistic store and a slower sibling flight lands diff --git a/packages/signals/docs/RULES-INDEX.md b/packages/signals/docs/RULES-INDEX.md index 799d96c23..5a2a5c7f2 100644 --- a/packages/signals/docs/RULES-INDEX.md +++ b/packages/signals/docs/RULES-INDEX.md @@ -52,7 +52,7 @@ Status legend: **live** stated and standing · **ruled** carries an explicit rul | id | status | defined | cited in src | cited in tests | statement (at definition) | |---|---|---|---|---|---| | F-1 | live | `docs/RULES-FUNDAMENTALS.md:45` | boundaries.ts×5 constants.ts×1 core.ts×4 effect.ts×2 guesses.ts×3 lanes.ts×13 scheduler.ts×2 seat.ts×3 verdict.ts×6 optimistic.ts×4 | async-reads-ahead-matrix.test.ts×2 async-reads-ahead-second-write.test.ts×1 blank-rows-4831.test.ts×1 deep-snapshot-after-action.test.ts×7 errored-held-mount-staged-error-4480.test.ts×1 errored-list-recovery-held-4526.test.ts×1 errored-recovery-fresh-loading-4627.test.ts×2 errored-recovery-stale-memo-4592.test.ts×1 ispending-async-derivation-4677.test.ts×3 ispending-memo-wrapped-asker-4778.test.ts×1 landing-frame-verdict-memo.test.ts×1 latest-beside-staged-read-4365.test.ts×1 latest-derived-held-error-guess-lane-4106.test.ts×1 latest-snapshot-scope-4570.test.ts×1 lean.test.ts×2 loading-on-held-guess-4987.test.ts×1 loading-on-latest-fallback-4337.test.ts×1 loading-reveal-held-outside-4593.test.ts×1 midflight-memo-over-reask-4504.test.ts×1 optimistic-guess-beside-reask-4824.test.ts×2 optimistic-guess-entangled-async-4577.test.ts×2 optimistic-guess-memo-binding-4561.test.ts×4 optimistic-guess-over-staged-error-4751.test.ts×1 optimistic-guess-parked-question-4559.test.ts×1 optimistic-guess-second-async-memo-4577.test.ts×1 optimistic-guess-split-bindings-4536.test.ts×1 optimistic-held-error-untracked-read-4489.test.ts×1 optimistic-lane-seam-loop-4643.test.ts×2 optimistic-list-push-filter-push-4642.test.ts×2 optimistic-outside-reask-4690.test.ts×2 optimistic-question-change-4336.test.ts×3 optimistic-refresh-late-shared-memo-4576.test.ts×1 optimistic-shared-effect-question-4536.test.ts×1 projection-chain-lane-4762.test.ts×1 projection-guess-replace-4861.test.ts×1 repark-drops-unreached-source-4541.test.ts×1 rows-rebuilt-sibling-refresh-4864.test.ts×1 optimistic-landing-model.test.ts×1 switch-under-guess-holds.test.ts×1 tracked-effect-staged-dep-4606-4607.test.ts×1 unread-derive-midflight-mount-4491.test.ts×1 verdict-memo-flight-no-reask.test.ts×1 verdict-memo-under-held-memo-4050.test.ts×1 verdict-probe-committed-4648.test.ts×2 verdict-probe-landing-4648.test.ts×1 verdict-seat-merged-lane-4427.test.ts×1 | The screen is whole | -| F-2 | live | `docs/RULES-FUNDAMENTALS.md:53` | core.ts×1 effect.ts×1 lanes.ts×5 scheduler.ts×2 seat.ts×3 verdict.ts×2 optimistic.ts×1 projection.ts×1 store.ts×1 | async-reads-ahead-edges.test.ts×2 async-reads-ahead-matrix.test.ts×3 async-reads-ahead-second-write.test.ts×1 direction-rule-probe.test.ts×1 error-is-an-answer.test.ts×1 errored-fallback-verdict-memo-reset.test.ts×1 errored-held-mount-staged-error-4480.test.ts×2 first-load-superseded-answer-4569.test.ts×2 lane-unshown-leaf-4338.test.ts×1 lean.test.ts×3 loading-on-latest-fallback-4337.test.ts×2 loading-reveal-held-outside-4593.test.ts×1 midflight-memo-over-reask-4504.test.ts×2 optimistic-held-write-leak.test.ts×1 optimistic-nested-action-refresh-4576.test.ts×1 optimistic-question-change-4336.test.ts×1 optimistic-refresh-late-shared-memo-4576.test.ts×1 settle-diamond-revisit.test.ts×1 optimistic-landing-model.test.ts×1 switch-under-guess-holds.test.ts×1 try-catch-reactive-read.test.ts×1 unread-derive-midflight-mount-4491.test.ts×2 verdict-memo-flight-no-reask.test.ts×1 verdict-probe-committed-4648.test.ts×1 | A change that needs async to be shown is held; the screen keeps what it showed | +| F-2 | live | `docs/RULES-FUNDAMENTALS.md:53` | async.ts×1 core.ts×1 effect.ts×1 lanes.ts×5 scheduler.ts×2 seat.ts×3 verdict.ts×2 optimistic.ts×1 projection.ts×1 store.ts×1 | async-reads-ahead-edges.test.ts×2 async-reads-ahead-matrix.test.ts×3 async-reads-ahead-second-write.test.ts×1 direction-rule-probe.test.ts×1 error-is-an-answer.test.ts×1 errored-fallback-verdict-memo-reset.test.ts×1 errored-held-mount-staged-error-4480.test.ts×2 first-load-superseded-answer-4569.test.ts×2 lane-unshown-leaf-4338.test.ts×1 lean.test.ts×3 loading-on-latest-fallback-4337.test.ts×2 loading-reveal-held-outside-4593.test.ts×1 midflight-memo-over-reask-4504.test.ts×2 optimistic-held-write-leak.test.ts×1 optimistic-nested-action-refresh-4576.test.ts×1 optimistic-question-change-4336.test.ts×1 optimistic-refresh-late-shared-memo-4576.test.ts×1 optimistic-store-derive-settled-before-sibling.test.ts×1 settle-diamond-revisit.test.ts×1 optimistic-landing-model.test.ts×1 switch-under-guess-holds.test.ts×1 try-catch-reactive-read.test.ts×1 unread-derive-midflight-mount-4491.test.ts×2 verdict-memo-flight-no-reask.test.ts×1 verdict-probe-committed-4648.test.ts×1 | A change that needs async to be shown is held; the screen keeps what it showed | | F-3 | live | `docs/RULES-FUNDAMENTALS.md:61` | boundaries.ts×6 async.ts×1 core.ts×2 lanes.ts×1 scheduler.ts×1 verdict.ts×2 index.ts×1 | errored-heal-disposed-reader-4373.test.ts×1 errored-heal-memo-reader-4644.test.ts×1 errored-memo-over-output-held-reject-4640.test.ts×1 lane-dissolve-disposed-member-4613.test.ts×2 lane-hold-staged-error-4841.test.ts×1 lean.test.ts×2 loading-on-errorboundary-through-4639.test.ts×1 | A reader holds only while it is the display | | F-4 | live | `docs/RULES-FUNDAMENTALS.md:69` | boundaries.ts×4 core.ts×3 lanes.ts×1 projection.ts×1 | derived-store-recovery-wake.test.ts×1 error-is-an-answer.test.ts×1 errored-memo-over-output-held-reject-4640.test.ts×1 errored-recovery-fresh-loading-4627.test.ts×3 errored-recovery-stale-memo-4592.test.ts×1 issue-3800-repro.test.ts×2 latest-memo-inline-parity.test.ts×1 loading-on-errorboundary-sibling-4638.test.ts×1 loading-on-errorboundary-through-4639.test.ts×1 loading-on-latest-fallback-4337.test.ts×1 | An armed boundary catches: what is pending under it holds nothing outside it | | F-5 | live | `docs/RULES-FUNDAMENTALS.md:77` | boundaries.ts×1 | lean.test.ts×1 loading-on-errorboundary-sibling-4638.test.ts×1 loading-on-held-change-4605.test.ts×2 loading-reveal-held-outside-4593.test.ts×1 | A disarmed boundary forwards: it keeps its content and holds like any reader, until `on` arms it again | @@ -96,7 +96,7 @@ Status legend: **live** stated and standing · **ruled** carries an explicit rul | D-30 | live | `docs/RULES-DERIVED.md:191` | projection.ts×1 store.ts×2 | derived-store-first-landing-verdict.test.ts×1 derived-store-ispending-boundary-4269.test.ts×1 derived-store-latest-seed-4355.test.ts×1 unread-derive-midflight-mount-4491.test.ts×3 | A derived store's seed is a draft, never an observable value | | D-31 | live | `docs/RULES-DERIVED.md:199` | lanes.ts×1 seat.ts×1 | optimistic-keyed-fold.test.ts×1 optimistic-live-echo-3898.test.ts×1 optimistic-outside-reask-4690.test.ts×1 optimistic-second-guess-reask-4629.test.ts×1 until-memo-confirmation-3943.test.ts×1 | `resolve`, `until` and `refresh` deliver by the hold they are called in | | D-32 | live | `docs/RULES-DERIVED.md:213` | — | — | Nothing shows a write before its flush; a guess with nothing to be optimistic over is void | -| D-33 | live | `docs/RULES-DERIVED.md:217` | boundaries.ts×1 guesses.ts×8 lanes.ts×4 scheduler.ts×1 optimistic.ts×5 | guess-read-entangles-4788.test.ts×1 guess-read-same-tick-4788.test.ts×1 guess-read-structure-4812.test.ts×1 optimistic-add-placeholder-beside-reorder-4897.test.ts×1 optimistic-array-structural-guesses-4793.test.ts×2 optimistic-guess-over-staged-error-4751.test.ts×1 optimistic-key-guess-reask-4329.test.ts×4 optimistic-lane-seam-loop-4643.test.ts×2 optimistic-layered-filter-4336.test.ts×3 optimistic-list-push-filter-push-4642.test.ts×2 optimistic-nested-action-refresh-4576.test.ts×1 optimistic-outside-reask-4690.test.ts×6 optimistic-question-change-4336.test.ts×3 optimistic-second-guess-held-staging-4825.test.ts×1 optimistic-second-guess-reask-4629.test.ts×2 optimistic-second-log-guess-4666.test.ts×3 optimistic-landing-model.test.ts×2 | An optimistic value lives exactly as long as the hold it was made over; same-slot writes entangle, disjoint slots do not | +| D-33 | live | `docs/RULES-DERIVED.md:217` | boundaries.ts×1 guesses.ts×8 lanes.ts×4 scheduler.ts×1 optimistic.ts×5 | guess-read-entangles-4788.test.ts×1 guess-read-same-tick-4788.test.ts×1 guess-read-structure-4812.test.ts×1 optimistic-add-placeholder-beside-reorder-4897.test.ts×1 optimistic-array-structural-guesses-4793.test.ts×2 optimistic-guess-over-staged-error-4751.test.ts×1 optimistic-key-guess-reask-4329.test.ts×4 optimistic-lane-seam-loop-4643.test.ts×2 optimistic-layered-filter-4336.test.ts×3 optimistic-list-push-filter-push-4642.test.ts×2 optimistic-nested-action-refresh-4576.test.ts×1 optimistic-outside-reask-4690.test.ts×6 optimistic-question-change-4336.test.ts×3 optimistic-second-guess-held-staging-4825.test.ts×1 optimistic-second-guess-reask-4629.test.ts×2 optimistic-second-log-guess-4666.test.ts×3 optimistic-store-derive-settled-before-sibling.test.ts×1 optimistic-landing-model.test.ts×2 | An optimistic value lives exactly as long as the hold it was made over; same-slot writes entangle, disjoint slots do not | | D-34 | live | `docs/RULES-DERIVED.md:225` | async.ts×3 core.ts×6 dev.ts×3 guesses.ts×8 lanes.ts×12 scheduler.ts×4 seat.ts×8 types.ts×1 verdict.ts×2 hooks.ts×1 optimistic.ts×18 reconcile.ts×1 store.ts×2 | blank-heading-4834.test.ts×1 errored-list-recovery-held-4526.test.ts×1 held-truth-lane-only.test.ts×1 lane-dissolve-disposed-member-4613.test.ts×1 lean.test.ts×1 loading-on-held-change-4605.test.ts×1 loading-on-held-filter-refresh-4379.test.ts×1 loading-on-latest-fallback-4337.test.ts×1 optimistic-guess-beside-reask-4824.test.ts×2 optimistic-guess-memo-binding-4561.test.ts×3 optimistic-guess-over-staged-error-4751.test.ts×1 optimistic-guess-parked-question-4559.test.ts×1 optimistic-guess-split-bindings-4536.test.ts×1 optimistic-held-error-untracked-read-4489.test.ts×2 optimistic-key-guess-reask-4329.test.ts×4 optimistic-keyed-fold.test.ts×3 optimistic-lane-seam-loop-4643.test.ts×2 optimistic-list-push-filter-push-4642.test.ts×4 optimistic-outside-reask-4690.test.ts×3 optimistic-question-change-4336.test.ts×8 optimistic-read-lane-not-transaction-3698.test.ts×1 optimistic-reask-over-held-write-4887.test.ts×1 optimistic-retoggle-after-refetch-4869.test.ts×1 optimistic-second-guess-reask-4629.test.ts×1 optimistic-second-log-guess-4666.test.ts×1 optimistic-write-while-loading-4795.test.ts×2 projection-chain-lane-4762.test.ts×1 projection-guess-replace-4861.test.ts×1 projection-lane-length-4631.test.ts×1 rows-rebuilt-sibling-refresh-4864.test.ts×1 spec-async-semantics.test.ts×3 derived-latest-confirmed-key.test.ts×3 superseded-before-first-commit.test.ts×2 visibility-oracle.states.ts×3 | A different truth corrects the graph now and the screen at the commit; what the screen never showed is void | | D-35 | live | `docs/RULES-DERIVED.md:233` | lanes.ts×1 optimistic.ts×1 | optimistic-guess-split-bindings-4536.test.ts×1 optimistic-layered-filter-4336.test.ts×2 optimistic-list-push-filter-push-4642.test.ts×6 optimistic-outside-reask-4690.test.ts×1 optimistic-second-guess-reask-4629.test.ts×1 optimistic-second-log-guess-4666.test.ts×1 | Provenance: an older question's answer never corrects a newer guess; the body's end corrects what nothing authoritative is answering | | D-36 | live | `docs/RULES-DERIVED.md:237` | — | — | A resting optimistic node is a plain memo | diff --git a/packages/signals/src/core/async.ts b/packages/signals/src/core/async.ts index d9b4636e6..5d0097b5b 100644 --- a/packages/signals/src/core/async.ts +++ b/packages/signals/src/core/async.ts @@ -96,13 +96,14 @@ function clearPendingSources(el: Computed): void { // A rejection-pending clears only through the settle walk over the source's // subscribers, so it can retry only when a live dep is the source or carries -// it. A disposed dep is unlinked and holds nothing (F-3, #5003). +// it. A disposed dep is unlinked and holds nothing (F-3, #5003). A source that +// has settled has no walk to come: linked directly, it holds nothing (F-2). export function retryReaches(el: Computed, source: any): boolean { for (let d = el._deps; d; d = d._nextDep) { const dep = d._dep as Computed; if ( !(dep._flags & REACTIVE_DISPOSED) && - (dep === source || dep._x?._pendingSources?.has(source)) + (dep === source ? dep._statusFlags & STATUS_PENDING : dep._x?._pendingSources?.has(source)) ) return true; } diff --git a/packages/signals/tests/optimistic-store-derive-settled-before-sibling.test.ts b/packages/signals/tests/optimistic-store-derive-settled-before-sibling.test.ts new file mode 100644 index 000000000..8bd4064db --- /dev/null +++ b/packages/signals/tests/optimistic-store-derive-settled-before-sibling.test.ts @@ -0,0 +1,103 @@ +import { expect, test } from "vitest"; +import { + action, + createMemo, + createOptimistic, + createOptimisticStore, + createRenderEffect, + createRoot, + createSignal, + flush +} from "../src/index.js"; + +// One render effect reads a derived optimistic store over async memo `a`, +// async memo `b`, and a guess an action made. The action re-asks both; `a` +// answers first and `b` answers unchanged, so the effect never re-runs past +// `b`. The store's derive settles with `a`, and the effect, linked to the +// derive by the pass that saw its flight, must stop waiting on it: the change +// reveals once every flight has landed (F-2), and the guess ends with the +// hold it was made over (D-33). +const tick = async () => { + for (let i = 0; i < 4; i++) { + await new Promise(r => setTimeout(r, 0)); + flush(); + } +}; + +test.each(["store", "signal"] as const)( + "a guess beside an optimistic %s and a slower sibling flight lands when both answer", + async kind => { + const asks: { key: string; res: (v: any) => void }[] = []; + const ask = (key: string) => new Promise(res => asks.push({ key, res })); + const answer = async (key: string, v: any) => { + const i = asks.findIndex(q => q.key === key); + expect(i).toBeGreaterThanOrEqual(0); + asks.splice(i, 1)[0].res(v); + await tick(); + }; + + const [version, setVersion] = createSignal(0); + const [status, setStatus] = createSignal("idle"); + const [revision, announce] = createSignal(0); + let held: () => boolean = () => false; + let screen = ""; + let shownStatus = ""; + let dispose!: () => void; + createRoot(d => { + dispose = d; + const a = createMemo(() => ask<{ id: string }[]>(`a:${version()}`)); + const b = createMemo(() => ask(`b:${version()}`)); + let list: () => string; + if (kind === "store") { + const [rows] = createOptimisticStore(() => a().map(r => ({ ...r })), [], { key: "id" }); + list = () => rows.map(r => r.id).join(); + } else { + const [rows] = createOptimistic(() => a()); + list = () => + rows() + .map(r => r.id) + .join(); + } + createRenderEffect( + () => `${list()}|${b()}|${(revision(), held())}`, + v => { + screen = v; + } + ); + createRenderEffect(status, v => { + shownStatus = v; + }); + }); + flush(); + await answer("a:0", [{ id: "a" }]); + await answer("b:0", 2); + expect(screen).toBe("a|2|false"); + + let release!: () => void; + const run = action(function* () { + const [h, setH] = createOptimistic(false); + setH(true); + held = h; + queueMicrotask(() => announce(n => n + 1)); + yield new Promise(r => (release = r)); + setVersion(n => n + 1); + }); + setStatus("submitting"); + const done = run(); + await tick(); + expect(screen).toBe("a|2|true"); + expect(shownStatus).toBe("idle"); + + release(); + await tick(); + await answer("a:1", [{ id: "a" }]); + await answer("b:1", 2); + await done; + await tick(); + + expect(asks).toEqual([]); + expect(screen).toBe("a|2|false"); + expect(shownStatus).toBe("submitting"); + dispose(); + } +); From eec58ab25566c141dcab0f944f33d8c8bdce7876 Mon Sep 17 00:00:00 2001 From: Marve10s Date: Mon, 23 Nov 2026 14:27:09 +0300 Subject: [PATCH 3/8] fix(web): send an empty revalidate declaration as a non-empty header --- .changeset/fix-web-empty-revalidate-header.md | 5 +++++ packages/web/server-functions/src/server.ts | 3 ++- packages/web/src/response.ts | 3 ++- .../web/test/runtime/redirect-href.spec.js | 9 ++++++++ .../server-functions-outcome-digest.spec.tsx | 21 +++++++++++++++++++ 5 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 .changeset/fix-web-empty-revalidate-header.md diff --git a/.changeset/fix-web-empty-revalidate-header.md b/.changeset/fix-web-empty-revalidate-header.md new file mode 100644 index 000000000..4d3fe172f --- /dev/null +++ b/.changeset/fix-web-empty-revalidate-header.md @@ -0,0 +1,5 @@ +--- +"@solidjs/web": patch +--- + +An empty `revalidate` declaration (`[]` or `""`) is now sent as `X-Revalidate: ,` instead of an empty header value, which intermediaries such as CDNs drop, turning "revalidate nothing" into "revalidate everything". diff --git a/packages/web/server-functions/src/server.ts b/packages/web/server-functions/src/server.ts index a7898ae21..1a7ea8357 100644 --- a/packages/web/server-functions/src/server.ts +++ b/packages/web/server-functions/src/server.ts @@ -2338,7 +2338,8 @@ async function foldFlightData(hooks, event, headers, outcome, context = {}) { // produce data for) and for redirects leaving the app's origin. function digestOutcome(event, outcome) { const { request, response } = outcome; - outcome.revalidateKeys = response?.headers.get(REVALIDATE_HEADER)?.split(","); + const declared = response?.headers.get(REVALIDATE_HEADER); + outcome.revalidateKeys = declared === "," ? [""] : declared?.split(","); outcome.foldedHeaders = foldSetCookies(request.headers, [ ...(event.response?.headers?.getSetCookie() ?? []), ...(response?.headers?.getSetCookie() ?? []) diff --git a/packages/web/src/response.ts b/packages/web/src/response.ts index 08fcbf7de..b88003db9 100644 --- a/packages/web/src/response.ts +++ b/packages/web/src/response.ts @@ -155,7 +155,7 @@ export interface ResponseHelperInit extends ResponseInit { * scopes: omitted sends no header — the host's default (Solid Router * revalidates everything after any mutation, form action or direct call; * a router without that convention reloads only what it owns); an empty - * list (or `""`) sends an empty header — nothing, explicitly; `REVALIDATE_ALL` (`"*"`) — every entry, + * list (or `""`) sends `,`, a header naming no key — nothing, explicitly; `REVALIDATE_ALL` (`"*"`) — every entry, * whatever the host's default. How named keys are matched (prefixes, * namespaces) is each integration's business. */ @@ -219,6 +219,7 @@ function initWithRevalidate(init: number | ResponseHelperInit = {}) { ); } headers.set(REVALIDATE_HEADER, keys); + if (!headers.get(REVALIDATE_HEADER)) headers.set(REVALIDATE_HEADER, ","); } return { responseInit, headers }; } diff --git a/packages/web/test/runtime/redirect-href.spec.js b/packages/web/test/runtime/redirect-href.spec.js index 988ac8ff3..b7b79dd44 100644 --- a/packages/web/test/runtime/redirect-href.spec.js +++ b/packages/web/test/runtime/redirect-href.spec.js @@ -109,4 +109,13 @@ describe("composed response headers refuse rather than overflow (#3131)", () => const ordinary = reload({ revalidate: ["orders", "orders:list"] }); expect(ordinary.headers.get(REVALIDATE_HEADER)).toBe("orders,orders:list"); }); + + it("writes an empty revalidate declaration as a non-empty header naming no key", () => { + for (const revalidate of [[], "", [""], " \t "]) { + expect(reload({ revalidate }).headers.get(REVALIDATE_HEADER)).toBe(","); + expect(redirect("/done", { revalidate }).headers.get(REVALIDATE_HEADER)).toBe(","); + } + expect(reload().headers.has(REVALIDATE_HEADER)).toBe(false); + expect(reload({ revalidate: "\u00a0*" }).headers.get(REVALIDATE_HEADER)).toBe("\u00a0*"); + }); }); diff --git a/packages/web/test/server/server-functions-outcome-digest.spec.tsx b/packages/web/test/server/server-functions-outcome-digest.spec.tsx index 49be2121b..4779f4cd8 100644 --- a/packages/web/test/server/server-functions-outcome-digest.spec.tsx +++ b/packages/web/test/server/server-functions-outcome-digest.spec.tsx @@ -212,6 +212,27 @@ describe("the invalidation scope", () => { expect(all.revalidateKeys).toEqual(["*"]); }); + it("answers an empty declaration with a non-empty header that names no key", async () => { + registerServerFunction("digest-empty-wire", async () => respond({}, { revalidate: [] })); + + let outcome!: ServerFunctionOutcome; + const response = await handleServerFunctionRequest( + post("digest-empty-wire", { referer: "https://app.example/cart" }), + { + createEvent, + collectFlightData: (_event, received) => { + outcome = received; + return { collected: true }; + } + } + ); + + const declared = response.headers.get("X-Revalidate"); + expect(declared).toBe(","); + expect(declared!.split(",").filter(Boolean)).toEqual([]); + expect(outcome.revalidateKeys).toEqual([""]); + }); + it("the helpers refuse the all key beside named keys", () => { // "everything and also these" is a mistake, not a scope — refused at // the helper, inside the function body, so it lands on the ordinary From c5eb10444abdacff9ec5de20e148b27d153b2c5f Mon Sep 17 00:00:00 2001 From: Marve10s Date: Mon, 23 Nov 2026 15:40:53 +0300 Subject: [PATCH 4/8] fix(compiler): treat only a leading comment equal to the static marker as the marker --- .../compiler-static-marker-exact-comment.md | 5 +++ .../coveragePragmas/code.js | 7 ++++ .../coveragePragmas/expected.js | 3 +- .../compiler/__tests__/parity-probes.test.js | 29 +++++++++++++ packages/compiler/__tests__/transform.test.js | 24 +++++++++++ packages/compiler/src/dom/spread.rs | 20 ++++++--- packages/compiler/src/shared/attr_plan.rs | 19 ++++----- packages/compiler/src/shared/classify.rs | 15 +++---- .../compiler/src/shared/component_children.rs | 14 ++++--- packages/compiler/src/shared/utils.rs | 41 ++++++++++++++++++- 10 files changed, 142 insertions(+), 35 deletions(-) create mode 100644 .changeset/compiler-static-marker-exact-comment.md diff --git a/.changeset/compiler-static-marker-exact-comment.md b/.changeset/compiler-static-marker-exact-comment.md new file mode 100644 index 000000000..7cbc16c8c --- /dev/null +++ b/.changeset/compiler-static-marker-exact-comment.md @@ -0,0 +1,5 @@ +--- +"@solidjs/compiler": patch +--- + +Only treat an expression's first leading comment as the static marker when its text is exactly the marker, as the Babel plugin does, so comments that merely mention it no longer freeze the binding. diff --git a/packages/babel-plugin/test/__shared_fixtures__/coveragePragmas/code.js b/packages/babel-plugin/test/__shared_fixtures__/coveragePragmas/code.js index d554c679b..6e00f2546 100644 --- a/packages/babel-plugin/test/__shared_fixtures__/coveragePragmas/code.js +++ b/packages/babel-plugin/test/__shared_fixtures__/coveragePragmas/code.js @@ -171,3 +171,10 @@ export const stackedBeforeAndOwn = ( ); + +export const beforeComponentMentioningMarker = ( + + {/* istanbul ignore next */} + {/* not @static */ state.value} + +); diff --git a/packages/babel-plugin/test/__shared_fixtures__/coveragePragmas/expected.js b/packages/babel-plugin/test/__shared_fixtures__/coveragePragmas/expected.js index 7a0820d39..345860154 100644 --- a/packages/babel-plugin/test/__shared_fixtures__/coveragePragmas/expected.js +++ b/packages/babel-plugin/test/__shared_fixtures__/coveragePragmas/expected.js @@ -28,7 +28,8 @@ const expected = { // Incoming + own both lead Child's getter (#4701). stackedBeforeAndOwn: { Child: ["/* istanbul ignore next */", "/* c8 ignore next */"] - } + }, + beforeComponentMentioningMarker: { Child: ["/* istanbul ignore next */"] } }; exports.expectedFor = function expectedFor(_generate) { diff --git a/packages/compiler/__tests__/parity-probes.test.js b/packages/compiler/__tests__/parity-probes.test.js index c858ca72b..873c0e215 100644 --- a/packages/compiler/__tests__/parity-probes.test.js +++ b/packages/compiler/__tests__/parity-probes.test.js @@ -1295,6 +1295,35 @@ const a = ; `, "static marker in condition branch": ` const a =
{cond() ? /*@static*/ x() : y()}
; +`, + "static marker named inside a comment stays dynamic": ` +const a =
{/* see @staticMethod */ text()}
; +const b =
; +const c =
{cond() ? /* not @static */ x() : y()}
; +`, + "static marker as second comment stays dynamic": ` +const a =
{/* note */ /* @static */ text()}
; +`, + "jsdoc static marker stays dynamic": ` +const a =
{/** @static */ text()}
; +`, + "static marker text inside a spread stays dynamic": ` +const a =
; +const b =
; +`, + "static marker line comment and parentheses": ` +const a =
{/* @static */ (text())}{(/* @static */ text())}
; +const b =
; +const c =
; +`, + "static marker trimmed and skipped as ECMAScript whitespace": ` +const a =
{/* @static */\uFEFF text()}
; +const b =
; +`, + "static marker followed by a next-line character stays dynamic": ` +const a =
{/* @static\u0085 */ text()}
; +const b =
; `, // --- Round 9: spread children through the unified classifier. Babel's diff --git a/packages/compiler/__tests__/transform.test.js b/packages/compiler/__tests__/transform.test.js index 754cb8b2d..2de01d695 100644 --- a/packages/compiler/__tests__/transform.test.js +++ b/packages/compiler/__tests__/transform.test.js @@ -376,6 +376,19 @@ describe("@solidjs/compiler transform", () => { expect(result.code).toContain("get other()"); }); + it("only treats a comment that is exactly the custom static marker as the marker", () => { + const result = transform( + "const view = ;", + { + filename: "input.jsx", + moduleName: "r-dom", + staticMarker: "once" + } + ); + + expect(result.code).toContain("get value()"); + }); + it("accepts validate false as an output-preserving option", () => { const result = transform("