[2.0 rc.20 / next] `deep()`/`snapshot()` return the pre-action store when an action that wrote before and after a `yield` lands
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 25/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- typescript
- 領域
- frontend
調査の方向性
Start with the repro test in packages/signals/tests/ that imports action, deep, snapshot and createStore from ../src/index.js. Compare the held-landing visibility check used by deep()/snapshot() with the per-key read path, and see how the earlier fix in aa03f76e (#3147) shares that decision. Done when deep(state) and snapshot(state) match the store after an action with writes before and after a yield lands.
索引モデルが issue の本文から書いたものです。
説明
Describe the bug
When an action writes a store before and after a yield, the computations that re-run when it lands see its writes through per-key reads (state.a), but deep(state) and snapshot(state) in the same run return the store as it was before the action. They miss the write made before the yield as well.
Nothing re-runs afterwards, so the stale value sticks:
- An effect over
deep(state), like the persistence example in the stores RFC (createEffect(() => deep(store), snapshot => saveToLocalStorage(JSON.stringify(snapshot)))), receives the pre-action state and doesn't run again. createMemo(() => deep(state))keeps returning{ a: 0, b: 0 }after everything has settled, while the store holds{ a: 1, b: 1 }andsnapshot(state)read outside any computation returns{ a: 1, b: 1 }.
This looks related to #3147, fixed in aa03f76e by having deep()/snapshot() and per-key readers share one held-landing visibility decision. That issue was the reverse case: deep() ran ahead of per-key reads while a transaction held a landing. Here the action has landed and per-key reads show it, but deep()/snapshot() still answer as if it were held.
Your Example Website or App
Inline below: a vitest test for packages/signals/tests/ that uses only the package's own exports.
Steps to Reproduce the Bug or Issue
Drop this into packages/signals/tests/ and run it:
import { expect, it } from "vitest";
import { action, createEffect, createRoot, createStore, deep, flush, snapshot } from "../src/index.js";
const settle = async () => {
for (let i = 0; i < 4; i++) {
await new Promise(r => setTimeout(r, 0));
flush();
}
};
it("deep()/snapshot() see an action's writes when it lands", async () => {
const [state, setState] = createStore({ a: 0, b: 0 });
const seen: any[] = [];
createRoot(() =>
createEffect(
() => ({ deep: deep(state), snap: snapshot(state), a: state.a, b: state.b }),
v => void seen.push(v)
)
);
await settle();
let release!: () => void;
const gate = new Promise<void>(r => (release = r));
action(function* () {
setState(d => { d.a = 1; });
yield gate;
setState(d => { d.b = 1; });
})();
await settle();
release();
await settle();
expect(seen.at(-1)).toEqual({ deep: { a: 1, b: 1 }, snap: { a: 1, b: 1 }, a: 1, b: 1 });
// actual: { deep: { a: 0, b: 0 }, snap: { a: 0, b: 0 }, a: 1, b: 1 }
});
What changes the outcome (deep(state) in the run after the action lands, same setup):
| Case | Result |
|---|---|
The same writes without action (generator stepped by hand) |
✅ { a: 1, b: 1 } |
Action with a write before the yield only |
✅ { a: 1, b: 0 } |
Action with writes before and after the yield |
❌ { a: 0, b: 0 } |
createMemo(() => deep(state)), read after settling |
❌ { a: 0, b: 0 }; the store is { a: 1, b: 1 } |
The effect does re-run exactly once when the action lands, so the notification arrives; it's the values deep()/snapshot() read in that run that are stale.
Expected behavior
In the run where the action lands, deep(state) and snapshot(state) match per-key reads: { a: 1, b: 1 }. A memo over deep(state) ends up equal to the store.
Platform
next@ 50dec1b3a (2026-10-31), in the signals package's own vitest setup@solidjs/signals2.0.0-rc.20 from npm, both the dev (dist/dev.js) and prod (dist/prod/index.js) builds@solidjs/signals2.0.0-rc.19 (dev build)- Node 24.18.0, macOS 26.5.2
Additional context
Found while recording deep(store) from an effect after each commit.
- 主要言語
- TypeScript
- スター
- 36.2k
- フォーク
- 1.1k
- 平均マージ
- 11時間 5分
- マージ済み PR(30日)
- 475
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
solidjs/solid のほかの issue
-
難易度 4/5 3〜5日 初心者へのやさしさ 28/100
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 12/100
メンテナーはふだん 1 日以内に返信
-
[2.0 / next] <Errored> recovery shows a pending memo's answer to an older input beside the new inputオープン
難易度 4/5 3〜5日 初心者へのやさしさ 20/100
メンテナーはふだん 1 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 15/100
メンテナーはふだん 1 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 18/100
メンテナーはふだん 1 日以内に返信
似ている issue
-
Remove unused dependencies対応中かも @alastair-smith が今日担当しました。 オープンchore other
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
alastair-smith/card-games#384 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
code-yeongyu/senpi#5571 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
nexu-io/open-design#9262 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
friction
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
kentcdodds/kody#4753 ·
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
難易度 1/5 1時間未満 初心者へのやさしさ 62/100
lingdojo/kana-dojo#33508 · コメント 1 件 · リアクション 5 件 ·
メンテナーはふだん 1 日以内に返信