[2.0.4] A waiting action started from a cleanup holds back an effect's write that reacts to the same landing (follow-up to #5251)
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
- #5259 của @yumemi-thomas — đã đóng, không merge
Đá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
- 38/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- typescript
- Lĩnh vực
- frontend, performance
Hướng nghiên cứu
Start with core/scheduler.ts, where the issue attributes the delayed write to flushTransaction, and run the linked Solid playground reproduction to compare cleanup-started and button-started waits. Done means the unrelated total write lands immediately while the waiting action remains pending, with regression coverage preserving the action's own later writes. Account for linked PR #5259, which is closed without being merged.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
An action closes a panel and sets count. The panel's cleanup starts an action that writes nothing and just waits. An effect reacts to the new count by setting total. count shows right away, but total stays at its old value, pending, until the cleanup's action ends. Started from the close button instead of the cleanup, the same waiting action doesn't hold total.
Reproduction
Open in the Solid playground (2.0.4)
import { createSignal, createEffect, action, isPending, Show } from "solid-js";
// Writes nothing; waits until "2. finish" is clicked.
let release: (() => void) | undefined;
const wait = action(function* () {
yield new Promise<void>(r => (release = r));
});
function Panel() {
createEffect(
() => 1,
() => () => void wait() // the effect's cleanup starts the waiting action
);
return <p>panel is open</p>;
}
export default function App() {
const [open, setOpen] = createSignal(true);
const [count, setCount] = createSignal(0);
const [total, setTotal] = createSignal(0);
const close = action(function* () {
setOpen(false);
setCount(1);
});
// reacts to the landed count; unrelated to `wait`
createEffect(count, c => {
if (c) setTotal(c * 10);
});
return (
<>
<button onClick={() => close()}>1. close panel</button>
<button onClick={() => release?.()}>2. finish</button>
<Show when={open()}>
<Panel />
</Show>
<p>
count: {count()} | total: {total()}
{isPending(total) ? " (pending)" : ""}
</p>
</>
);
}
Steps
- Click 1. close panel. The cleanup starts
wait(). - Click 2. finish.
Expected
count: 1 | total: 10 after step 1. total's write is the effect's reaction to close, not part of wait, which writes nothing. They share nothing, and wait has staged nothing that total belongs to, so it commits without waiting for wait (D-4, D-9).
Actual
| after step 1 | after step 2 | |
|---|---|---|
cleanup starts wait() |
count: 1 | total: 0 (pending) |
count: 1 | total: 10 |
control: wait() called from the close button right after close(), no cleanup |
count: 1 | total: 10 |
count: 1 | total: 10 |
If the promise never settles, total never shows 10. Same in 2.0.4 and main (510bb8d01), dev and prod, and with #5242 applied.
A corrected guess is held the same way. save guesses "Guess" on a createOptimistic(async () => …), closes the panel, and waits. Meanwhile a refresh() outside save answers "Server B". When save ends, latest() and an untracked read give "Server B" and isPending is false, but the screen keeps "Guess" until wait ends (F-11: the correction reveals with the hold's other writes).
Cause
The cleanup runs while settle() lands close, and wait() opens a transaction that becomes the flush's flushTransaction. The effect's setTotal leaves another round in the same drain, and that round's seam parks total's write into wait's transaction (core/scheduler.ts). #5242 clears the leftover transaction at the end of flush() only when no round is left (if (!scheduled) flushTransaction = null;), so this case is unchanged. The underlying limit is that a seam parks a whole round into one transaction: a slice's writes belong to its action only because that action is the ambient flushTransaction when the round's seam runs, and nothing attributes a write to its action at the write. So clearing the transaction after every round releases total but also stops the cleanup action's own later writes from being held. A complete fix needs per-slice attribution at the write, or an in-flush slice getting a round of its own.
Related
- #5251: the same leftover transaction holds a later action from another flush. #5242 fixes that case.
- #5242
- 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ự
-
agents-window vscode api adoption
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
alefragnani/vscode-copy-word#126 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
opensro-dev/opensro#4949 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
agent:linux priority:high
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
fa0311/better-tokuly#1204 ·
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 73/100
saltbo/zpan#883 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement impeccable priority: low
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
nledford/Ladderback#1891 ·
Maintainer thường phản hồi trong vòng 1 ngày