Skip to content

Instantly share code, notes, and snippets.

@Peyton-Spencer
Created November 1, 2026 21:17
Show Gist options
  • Select an option

  • Save Peyton-Spencer/edae55128c740f01357d116844e3f7bd to your computer and use it in GitHub Desktop.

Select an option

Save Peyton-Spencer/edae55128c740f01357d116844e3f7bd to your computer and use it in GitHub Desktop.
Solid 2 unchanged async projection repro and rc.19 backport

Unchanged async projection settlement

Standalone reproduction for solidjs/solid#4493, plus a runtime backport for @solidjs/[email protected].

A projection reads an async memo and exposes an unchanged status leaf. After the memo refetches and resolves to its previous value, a memo reading that leaf stays pending. The refetch has finished.

Results

Tested on macOS with Node 26.8.2, using clean package installs on 2026-11-01.

Runtime Production Development Observe
Published rc.19 pending stays true; assertion fails same same
Published rc.19 with attached patch pending becomes false; passes same same
Published rc.20 pending stays true; assertion fails same same
next at d9b5a79e8c85b43e173696a570a0ea75fc687626 passes passes passes

The next row uses source bundles built with esbuild and the production/development/observe flag combinations. It does not test release packaging. The reproduction uses createProjection on rc.19 and the derived createStore overload when that export is absent.

Run

Save the files from this gist into one directory, then run:

npm install --ignore-scripts --no-audit --no-fund @solidjs/[email protected]
node repro.mjs
node --conditions=development repro.mjs
node --conditions=observe repro.mjs

Each run prints pending after unchanged resolution: true and fails the final assertion. The expected result is false.

To check the published rc.20 package:

npm install --ignore-scripts --no-audit --no-fund @solidjs/[email protected]
node repro.mjs

Apply the rc.19 backport

npm install --ignore-scripts --no-audit --no-fund @solidjs/[email protected]
git apply --directory=node_modules/@solidjs/signals rc19-backport.patch
node repro.mjs
node --conditions=development repro.mjs
node --conditions=observe repro.mjs

All three runs print pending after unchanged resolution: false and exit successfully.

The patch changes the published development, observe, and production artifacts. It notifies a projection family when its derive settles, including unchanged async recovery. It also retains the family wake marker until the derive has left its pending state. This is the backport we tested in our app; upstream's source fix in #4493 already passes this reproduction on the tested next commit.

The runtime patch derives from Solid's MIT-licensed package. It contains no application code or data.

diff --git a/dist/dev-shared.js b/dist/dev-shared.js
index cd854aeccb9b0d6cc184e17c5f23783901ec783f..97081c824986a709ad3491344a86ba566bb46427 100644
--- a/dist/dev-shared.js
+++ b/dist/dev-shared.js
@@ -3297,6 +3297,7 @@ function settlePendingSource(el, source = el) {
// re-parks can retain an abandoned self entry (source === el), which must
// retire in the same walk as its propagated copies.
removePendingSource(el, source);
+ if (!(el._statusFlags & (STATUS_PENDING | STATUS_ERROR))) el.fam?.st(0);
let scheduled = false;
let released;
const visited = new NewSet();
@@ -3331,6 +3332,10 @@ function settlePendingSource(el, source = el) {
} else {
node._statusFlags &= ~STATUS_PENDING;
if (!errored) setPendingError(node);
+ // A projection may recover without re-running when its upstream lands
+ // on the same value. Its leaves are not dependencies of the derive, so
+ // explicitly release the readers that familyStatus parked on it.
+ if (!errored) node.fam?.st(0);
// L2: a landing resumes the transaction waiting on it (maintainer: "it
// resumes the sync frame") — a held reader's re-pass over the landed
// value is that transaction's work, and the flush that carries it
diff --git a/dist/dev.js b/dist/dev.js
index 0f4ccb08e3d7da1de2d6c747cc79e39237022704..c2109c1b5587680c9a679913dd70f841d1b0e454 100644
--- a/dist/dev.js
+++ b/dist/dev.js
@@ -6705,7 +6705,7 @@ function errorFamily(fam) {
* settle — core's walk, from each leaf (the leaves are not the derive's
* dependents, so its own settle walk does not reach them). */
function settleFamily(fam) {
- if (!fam.woke) return;
+ if (!fam.woke || fam.node._statusFlags & STATUS_PENDING) return;
fam.woke = false;
const fw = fam.node;
forEachFamilyNode(fam, n => {
@@ -6718,6 +6718,7 @@ function settleFamily(fam) {
function familyStatus(status) {
if (status & STATUS_PENDING) wakeFamily(this);
else if (status & STATUS_ERROR) errorFamily(this);
+ else settleFamily(this);
}
function forEachFamilyNode(fam, fn) {
for (const t of fam.live) {
diff --git a/dist/observe/core/async.js b/dist/observe/core/async.js
index 04fab1ba5c7758b0c0543d8c7e5ac199f27b6fd2..b520db0266247a667694be1f40e7768a2720d203 100644
--- a/dist/observe/core/async.js
+++ b/dist/observe/core/async.js
@@ -190,6 +190,7 @@ function settlePendingSource(e, t = e) {
// re-parks can retain an abandoned self entry (source === el), which must
// retire in the same walk as its propagated copies.
removePendingSource(e, t);
+ if (!(e.m & (STATUS_PENDING | STATUS_ERROR))) e.fam?.st(0);
let n = false;
let r;
const o = new NewSet;
@@ -221,6 +222,8 @@ function settlePendingSource(e, t = e) {
} else {
s.m &= ~STATUS_PENDING;
if (!u) setPendingError(s);
+ // Release projection leaf readers on unchanged upstream recovery.
+ if (!u) s.fam?.st(0);
// L2: a landing resumes the transaction waiting on it (maintainer: "it
// resumes the sync frame") — a held reader's re-pass over the landed
// value is that transaction's work, and the flush that carries it
diff --git a/dist/observe/store/projection.js b/dist/observe/store/projection.js
index 6c0ceebad71d50e6721e193f3e7a20b133d967f2..acf5d8176dfbfa679bcd1460a37997668a281216 100644
--- a/dist/observe/store/projection.js
+++ b/dist/observe/store/projection.js
@@ -158,7 +158,7 @@ function cloneState(e, t) {
/** The flight landed: the readers the wake left pending on the derive
* settle — core's walk, from each leaf (the leaves are not the derive's
* dependents, so its own settle walk does not reach them). */ function settleFamily(e) {
- if (!e.woke) return;
+ if (!e.woke || e.node.m & STATUS_PENDING) return;
e.woke = false;
const t = e.node;
forEachFamilyNode(e, e => {
@@ -169,7 +169,7 @@ function cloneState(e, t) {
/** A source's status reached the derive by propagation (core
* `propagateStatus`), its pass not re-run: the family learns it as from the
* pass's own throw. */ function familyStatus(e) {
- if (e & STATUS_PENDING) wakeFamily(this); else if (e & STATUS_ERROR) errorFamily(this);
+ if (e & STATUS_PENDING) wakeFamily(this); else if (e & STATUS_ERROR) errorFamily(this); else settleFamily(this);
}
function forEachFamilyNode(e, t) {
diff --git a/dist/prod/core/async.js b/dist/prod/core/async.js
index 3ac5eccc96502c79347ba3f6ec27257faca2a639..52bf456836121fa83ba7af3f64917476511c180d 100644
--- a/dist/prod/core/async.js
+++ b/dist/prod/core/async.js
@@ -186,6 +186,7 @@ function settlePendingSource(e, n = e) {
// re-parks can retain an abandoned self entry (source === el), which must
// retire in the same walk as its propagated copies.
removePendingSource(e, n);
+ if (!(e.m & (STATUS_PENDING | STATUS_ERROR))) e.fam?.st(0);
let t = false;
let r;
const o = new NewSet;
@@ -217,6 +218,8 @@ function settlePendingSource(e, n = e) {
} else {
f.m &= ~STATUS_PENDING;
if (!u) setPendingError(f);
+ // Release projection leaf readers on unchanged upstream recovery.
+ if (!u) f.fam?.st(0);
// L2: a landing resumes the transaction waiting on it (maintainer: "it
// resumes the sync frame") — a held reader's re-pass over the landed
// value is that transaction's work, and the flush that carries it
diff --git a/dist/prod/store/projection.js b/dist/prod/store/projection.js
index 0f97e1a4f9280c291c875978c518db5a850cd098..c99586ea450ed9d66d31e6d4ae46bf5b9dbb7c65 100644
--- a/dist/prod/store/projection.js
+++ b/dist/prod/store/projection.js
@@ -156,7 +156,7 @@ function cloneState(e, t) {
/** The flight landed: the readers the wake left pending on the derive
* settle — core's walk, from each leaf (the leaves are not the derive's
* dependents, so its own settle walk does not reach them). */ function settleFamily(e) {
- if (!e.woke) return;
+ if (!e.woke || e.node.m & STATUS_PENDING) return;
e.woke = false;
const t = e.node;
forEachFamilyNode(e, e => {
@@ -167,7 +167,7 @@ function cloneState(e, t) {
/** A source's status reached the derive by propagation (core
* `propagateStatus`), its pass not re-run: the family learns it as from the
* pass's own throw. */ function familyStatus(e) {
- if (e & STATUS_PENDING) wakeFamily(this); else if (e & STATUS_ERROR) errorFamily(this);
+ if (e & STATUS_PENDING) wakeFamily(this); else if (e & STATUS_ERROR) errorFamily(this); else settleFamily(this);
}
function forEachFamilyNode(e, t) {
import assert from "node:assert/strict";
import * as solid from "@solidjs/signals";
const { createMemo, createRoot, createSignal, flush, isPending } = solid;
// Use the derived createStore overload when createProjection is absent.
const project = solid.createProjection ?? ((derive, seed) => solid.createStore(derive, seed)[0]);
async function drain() {
for (let i = 0; i < 4; i++) {
await Promise.resolve();
flush();
await new Promise(done => setTimeout(done, 0));
}
flush();
}
let resolve;
const state = createRoot(dispose => {
const [version, setVersion] = createSignal(0);
const source = createMemo(() => {
version();
return new Promise(done => { resolve = done; });
});
const metadata = project(draft => {
draft.value = source();
draft.status = "success";
}, { value: 0, status: "success" });
const status = createMemo(() => metadata.status);
return { dispose, status, setVersion };
});
try {
resolve(1);
await drain();
assert.equal(state.status(), "success");
state.setVersion(1);
flush();
assert.equal(isPending(state.status), true);
resolve(1); // Same answer: the projection does not need to run again.
await drain();
console.log("pending after unchanged resolution:", isPending(state.status));
assert.equal(isPending(state.status), false);
} finally {
state.dispose();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment