[2.0.4] An optimistic value set by a cleanup's action shows during an unrelated later action
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- 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
- Đình trệ
- Công nghệ
- javascript, typescript
Hướng nghiên cứu
Start with the landing loop in packages/signals/src/core/scheduler.ts and pending guess handling in packages/signals/src/core/guesses.ts; read D-33 in packages/signals/docs/RULES-DERIVED.md for the expected behavior. Reproduce the three-step case in the linked Solid playground, then inspect how the flush decides whether another round is needed. Done means the cleanup's unheld guess is dropped and guess remains 0 through the unrelated action; linked PR #5242 is already open.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
A branch's cleanup calls a synchronous action whose only write is setGuess(1) on a createOptimistic value. That action holds nothing, so the guess should be dropped and nobody should ever see 1. Instead the guess stays queued. The next action, which is unrelated to it and never touches guess, picks it up and shows 1 while it waits. On 2.0.4 and main, 1 also stays after that action ends.
Reproduction
Open in the Solid playground (2.0.4)
App.tsx (main.tsx renders <App /> into #app):
import { createSignal, createOptimistic, action, onCleanup, Show } from "solid-js";
// An optimistic flag that only a cleanup's action ever sets.
const [guess, setGuess] = createOptimistic(0);
const markClosed = action(function* () {
setGuess(1); // the action's only write: a guess with nothing held, so it should never show
});
function Panel() {
onCleanup(() => void markClosed());
return <p>panel is open</p>;
}
export default function App() {
const [open, setOpen] = createSignal(true);
const close = action(function* () {
setOpen(false);
});
// An action that never touches `guess`; it just waits until "finish" is clicked.
let release: (() => void) | undefined;
const [waiting, setWaiting] = createSignal(false);
const unrelated = action(function* () {
yield new Promise<void>(r => (release = r));
});
return (
<>
<button onClick={() => close()}>1. close panel</button>
<button
onClick={() => {
setWaiting(true);
unrelated();
}}
>
2. start unrelated action
</button>
<button
onClick={() => {
release?.();
setWaiting(false);
}}
>
3. finish it
</button>
<Show when={open()}>
<Panel />
</Show>
<p>
guess: {guess()} {waiting() ? "(unrelated action waiting)" : ""}
</p>
<p>Expected: guess stays 0 after every step.</p>
</>
);
}
Steps
- Click 1. close panel. The panel's cleanup calls
markClosed(), whose only write issetGuess(1). - Click 2. start unrelated action.
unrelatednever reads or writesguess; it just waits. - Click 3. finish it.
Expected
guess: 0 after every step. markClosed writes only a guess and holds nothing, so the guess is void: "one written in a frame that commits with nothing held is as if it never happened — nothing is applied, no effect sees it" (D-33 in packages/signals/docs/RULES-DERIVED.md). unrelated never touches guess, so it can't give the guess anything to be optimistic over either.
Actual
| version | after step 1 | after step 2 (unrelated waiting) |
after step 3 |
|---|---|---|---|
| 2.0.3 | guess: 0 |
guess: 1 |
guess: 0 |
| 2.0.4 | guess: 0 |
guess: 1 |
guess: 1 |
main (34485971a) |
guess: 0 |
guess: 1 |
guess: 1 |
On 2.0.3 the guess appears while unrelated runs and reverts when it ends. On 2.0.4 and main it also never reverts. That second half is the flush still pointing at a landed transaction, tracked in #5233; with a fix for #5233 the result goes back to 2.0.3's. The leak while unrelated waits is separate and is in all three versions.
Versions
@solidjs/signals/solid-js2.0.4- main at
34485971a - also present in 2.0.3 (the "while waiting" half)
Cause
The cleanup runs inside settle(), during the commits of the landing loop (packages/signals/src/core/scheduler.ts, the loop around line 1239 on main). By then this seam has already applied its guesses: applyGuessesHook(joined) runs near line 1114, before the loop. So setGuess(1) lands in the pending-guess list (pendingGuesses in core/guesses.ts) after the only point that would have judged it against this frame.
flush() then decides whether to run another round, near line 1076:
scheduled = dirtyQueue._max >= dirtyQueue._min || pendingNodes.length !== 0;
This doesn't count pending guesses, so the flush ends with the guess still queued. The next flush is the one unrelated starts. Its seam applies the leftover guess under unrelated's transaction, which opens a lane over that hold, and the guess shows until unrelated ends.
Counting pending guesses in that check (|| guessesWaiting() !== 0, through a hook as the other lane checks do) gives 0 0 0 [0] in a local experiment. The leftover guess is judged in the same flush, where nothing is held, and is dropped. I haven't run the full test suite on that change.
- 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ự
-
agentscan:mixed-signals pending triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
vueuse/vueuse#5737 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 9 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Marker-Inc-Korea/AutoRAG#2288 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Resources: New templates of Guangzhou Metro Line 13Có thể đã có người làm @rmt-svc đã nhận hôm nay. Đang mởresources
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 76/100
railmapgen/rmg-templates#2730 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
web
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày