[2.0.4] `latest()` over a keyed optimistic store counts a row the list still hides after an outside refresh (store case of #4689)
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- javascript, typescript
- Lĩnh vực
- frontend
Hướng nghiên cứu
Start with the pinned regression test in packages/signals/tests/held-truth-lane-only.test.ts and read the linked store fold in packages/signals/src/store/thinOptimistic.ts and latest read in packages/signals/src/core/verdict.ts. The issue says a leaf by leaf attempt mixed guessed rows with the refreshed length, so trace the whole-list behavior and the related async state notes. Done means the keyed store keeps latest() aligned with the displayed two rows after refetch, with the existing test updated or supplemented.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
An action removes a row from a keyed createOptimisticStore and waits. While it waits, an outside refresh() lands with the original three rows. The list keeps showing the two optimistic rows, as it should, but latest(() => items.length) jumps back to 3, so the page shows Count: 3 above two rows until the action settles.
This is the store example from #4689. That issue was closed as fixed by #4717, whose description lists this case under "Not built": "#4689 for a folded keyed arrangement (rows removed, the lane kept)". Main's rules also record it as not built, and a test pins today's behavior, but no open issue tracks it. This issue tracks that remaining case.
It is a known gap, but the ruling does not allow it: decision 3 says "#4689 is a bug under this" and was "Approved unscoped". On screen, the count disagrees with the rows right under it.
Playground
Open in the Solid playground (pinned to 2.0.4).
Steps
- Wait for Count: 3 and Rows: 1 2 3.
- Click Remove first row. The action runs
setItems(draft => { draft.shift(); })and waits. - Click Refetch, which calls
refresh(items)outside the action. It returns the same three rows. - Click Finish removal. The action ends with
refresh(items).
import { action, createOptimisticStore, For, latest, Loading, refresh } from "solid-js";
const rows = [{ id: 1 }, { id: 2 }, { id: 3 }];
function App() {
let finish: (() => void) | undefined;
const [items, setItems] = createOptimisticStore<{ id: number }[]>(async draft => {
await Promise.resolve();
draft.length = rows.length;
rows.forEach((row, i) => { draft[i] = { ...row }; });
}, [], { key: "id" });
const remove = action(function* () {
setItems(draft => { draft.shift(); });
yield new Promise<void>(resolve => { finish = resolve; });
refresh(items);
});
return (
<main>
<button onClick={remove}>Remove first row</button>
<button onClick={() => { refresh(items); }}>Refetch</button>
<button onClick={() => { finish?.(); }}>Finish removal</button>
<Loading fallback={<p>Loading</p>}>
<p>Count: {latest(() => items.length)}</p>
<p>Rows: <For each={items}>{row => <span>{row.id} </span>}</For></p>
</Loading>
</main>
);
}
Expected
Initial Count: 3 | Rows: 1 2 3
Remove first row Count: 2 | Rows: 2 3
Refetch lands Count: 2 | Rows: 2 3
Finish removal Count: 3 | Rows: 1 2 3
Rule D-22: "A slot that is displaying a guess has the guess as its newest value: latest of it shows the guess until the hold commits." D-22 · Decision 3
Actual
Initial Count: 3 | Rows: 1 2 3
Remove first row Count: 2 | Rows: 2 3
Refetch lands Count: 3 | Rows: 2 3
Finish removal Count: 3 | Rows: 1 2 3
After the refetch, plain reads give length 2 and rows 2,3. latest() gives length 3 and rows 1,2,3, and latest(() => items[0].id) gives 1, a row the list no longer shows. A single render effect reading [items.length, latest(() => items.length)] gets [2, 3]. isPending is not affected: it reads true after the refetch with or without key.
Versions tested
| Version or source | Plain / latest length after the refetch |
|---|---|
| 2.0.3, 2.0.4 | 2 / 3 |
a4bd02707, parent of #4717 |
2 / 3 |
46a72c0b3, #4717 |
2 / 3 |
Main 50a4bfd |
2 / 3 |
Same in development and production builds. The playground gives the frames above on 2.0.4 and on main.
With key: null, both reads stay at 2 until the action settles, on 2.0.4 and main.
Cause
The refresh lands under a shown list edit with a row removed, so the optimistic store folds the new list into the action's transaction and keeps the guessed list on screen. A latest() read of a folded guess returns the staged list as a whole, so it gets the refetched length and rows while render reads keep the guess. Store fold · latest read of a folded guess
Main documents this as the part of the rule that is not built, and a test pins today's behavior. Per the implementation notes, keeping the guess leaf by leaf was tried and mixed guessed rows with the refetched length, so the list has to be kept as a whole. D-34 status · Implementation note · Pinned test
Related
- #4689: the original report, with this store case and the signal case. Closed as fixed by #4717. Closing comment
- #4717: built decision 3 for a signal and a superseded keyed row, and listed this case under "Not built".
- #4695: recorded decision 3, the ruling that
latestshows a displayed guess.
- Ngôn ngữ chính
- TypeScript
- Star
- 37k
- Fork
- 1.2k
- Merge trung bình
- 8 giờ 43 phút
- Pull request đã merge (30 ngày)
- 365
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của solidjs/solid
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 38/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[2.0.4] Nested `<Errored>`: the outer boundary stays on an error the inner one rethrew, after the next error is one the inner one handlesCó thể đã có người làm @MilindChatrabhuji đã nhận 2 ngày trước. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của solidjs/solid
Issue tương tự
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 69/100
activepieces/activepieces#17974 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
OHDSI/Data2Evidence#3777 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
bug enhancement
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
AOSSIE-Org/PictoPy#1802 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 3 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Termix-SSH/Plugin-Snippets#26 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
agent-reported bug from-app needs-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
nightly-labs/openbot#20504 ·
Maintainer thường phản hồi trong vòng 1 ngày