[2.0.3 / main] After hydration, an onSettled write waits for an unrelated browser-only read under its own <Loading>, and a hydrated block disappears meanwhile (regression from rc.21)
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue nà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
- Sôi nổi
- Công nghệ
- bun, javascript, node.js, playwright, typescript
- Lĩnh vực
- frontend, testing-qa
Hướng nghiên cứu
Start with the bisected regression in @solidjs/signals: commit 9e02d02a (#4865), then compare the behavior with a4b40256 (#5085) using the self-contained repro in App.jsx, build.mjs, server.mjs, and run.mjs. Run repro.sh across the listed versions and inspect the transaction and verdict-lane behavior described in the report. Done means the browser-only read no longer delays the onSettled write and the hydrated overview remains visible while that read is pending.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Describe the bug
After hydration, a write made in onSettled waits for a browser-only async read that the write's own branch opens. That read sits under its own <Loading>. On 2.0.0-rc.22 through 2.0.3 the write never lands. On main (after #5085) it lands, but only when that unrelated read answers. Until then, a block the server rendered and the client hydrated disappears from the page.
It needs this shape:
- a server-adopted live source
list(an async iterable brandedSymbol.for("solid.LiveSource"), as@solidjs/router'sliveQuerybrands one), so the browser re-runs it after hydration; id = createMemo(() => latest(list)?.[0]);- a server-rendered live read keyed on
id, shown through a<Show>with a nested<Show>; - a browser-only (
ssrSource: "client") slow read keyed onid, mounted by anonSettledflag under its own<Loading>.
Each of these is needed. On main it passes without the nested <Show>, with id reading list() instead of latest(list), or when either read is not keyed on id. An intermediate memo between latest() and the readers (#4965's scope) is not needed. The narrowed accessor isn't either: a plain nested <Show> is enough.
<Show> has to stay a component. The repro compiles with @solidjs/compiler's dev: true, as our app's build does. With the production default (lowerShow, see #5092) the <Show>s are inlined and it passes.
Your Example Website or App
Self-contained repro below: SSR with renderToStream, hydration in Chromium (Playwright). Bun bundles the client.
Steps to Reproduce the Bug or Issue
App.jsx:
import { Show, Loading, createMemo, createSignal, latest, onSettled } from "solid-js";
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
// A live source branded the way @solidjs/router's liveQuery brands one: the server
// serializes its first value; after hydration the browser re-runs the compute, and
// this one answers `ms` later and stays open.
async function* gen(value, ms) {
if (typeof window !== "undefined") await sleep(ms);
yield value;
await new Promise(() => {});
}
function live(value, ms) {
const it = gen(value, ms);
it[Symbol.for("solid.LiveSource")] = true;
return it;
}
export function App() {
const list = createMemo(() => live(["a"], 200));
const id = createMemo(() => latest(list)?.[0]);
// Server-rendered, keyed on `id`.
const overview = createMemo(() => (id() ? live(5, 100) : undefined));
// Browser-only and slow, keyed on `id`: answers 1 s after it is asked.
const inbox = createMemo(() => (id() ? live([], 1000) : []), { ssrSource: "client", lazy: true });
const [hydrated, setHydrated] = createSignal(false);
onSettled(() => {
setHydrated(true);
});
return (
<main>
<i id="hydrated">{hydrated() ? "yes" : "no"}</i>
<Show when={hydrated()}>
<Loading fallback={null}>
<Show when={inbox().length > 0}>unread</Show>
</Loading>
</Show>
<Show when={overview()}>
<Show when={overview() > 1}>
<b id="overview">{overview()}</b>
</Show>
</Show>
</main>
);
}
build.mjs:
// Compiles App.jsx for the server and the browser with @solidjs/compiler (`dev: true`
// keeps <Show> a component), renders it with renderToStream, bundles the client.
import { transform } from "@solidjs/compiler";
import { readFileSync, writeFileSync } from "node:fs";
import { execSync } from "node:child_process";
const src = readFileSync("App.jsx", "utf8");
for (const generate of ["ssr", "dom"])
writeFileSync(`App.${generate}.mjs`, transform(src, { filename: "App.jsx", generate, hydratable: true, dev: true }).code);
writeFileSync("client-entry.mjs", `import { hydrate } from "@solidjs/web";
import { App } from "./App.dom.mjs";
hydrate(() => App(), document.getElementById("root"));\n`);
execSync("bun build client-entry.mjs --target=browser --production --outfile=client.js", { stdio: "ignore" });
execSync("node server.mjs > index.html", { stdio: "inherit", shell: true });
server.mjs:
import { renderToStream, generateHydrationScript } from "@solidjs/web";
import { App } from "./App.ssr.mjs";
let html = "";
await new Promise((resolve) => renderToStream(() => App()).pipe({ write: (c) => { html += c; }, end: resolve }));
process.stdout.write(`<!doctype html><html><head>${generateHydrationScript()}</head><body><div id="root">${html}</div><script src="client.js"></script></body></html>`);
run.mjs:
// Opens index.html in Chromium and prints each change of <main>'s text, with its time.
import { chromium } from "playwright";
const browser = await chromium.launch({ channel: "chromium" });
const page = await browser.newPage();
await page.addInitScript(() => {
window.changes = [];
const t0 = performance.now();
new MutationObserver(() => {
const text = document.querySelector("main")?.textContent;
if (text !== undefined && text !== window.last) {
window.last = text;
window.changes.push(`${Math.round(performance.now() - t0)} ms: ${text}`);
}
}).observe(document, { subtree: true, childList: true, characterData: true });
});
await page.goto(new URL("./index.html", import.meta.url).href);
await page.waitForTimeout(2000);
console.log((await page.evaluate(() => window.changes)).join("\n"));
await browser.close();
repro.sh:
#!/bin/bash
# usage: ./repro.sh <solid-js/@solidjs/web version> [@solidjs/signals version]
set -e
v=$1; s=${2:-$1}; d=v-$v-signals-$s; rm -rf $d; mkdir $d; cp App.jsx build.mjs server.mjs run.mjs $d/; cd $d
cat > package.json <<J
{ "private": true, "type": "module", "overrides": { "@solidjs/signals": "$s" } }
J
bun add -E solid-js@$v @solidjs/web@$v @solidjs/signals@$s @solidjs/[email protected] [email protected] >/dev/null 2>&1
node build.mjs && echo "solid-js/web $v, signals $s:" && node run.mjs
The overrides keep one @solidjs/signals: [email protected] asks for ^2.0.0-rc.21, which otherwise installs a nested 2.0.3 beside the pinned one (as #5073 noted).
$ ./repro.sh 2.0.0-rc.21
2 ms: no5
126 ms: yes5
$ ./repro.sh 2.0.0-rc.22 # the same for rc.23, 2.0.0, 2.0.1, 2.0.2 and 2.0.3
1 ms: no5
$ ./repro.sh 2.0.0-rc.21 2.0.0-rc.22
1 ms: no5
main: the 2.0.3 install with packages/signals/dist built at 99db9bce swapped in:
3 ms: no5
131 ms: no
1031 ms: yes5
Expected behavior
As on 2.0.0-rc.21: #hydrated reads yes when the list's re-run answers (~120 ms), and #overview stays on the page throughout. The browser-only read is under its own <Loading fallback={null}>, so the write that mounts it should not wait for its answer.
Actual:
- 2.0.0-rc.22 through 2.0.3:
#hydratedstaysnoforever. main(99db9bce, and a4b40256 / #5085 alone):#hydratedreadsyesonly when the browser-only read answers (~1 s). From ~130 ms until then,#overviewis gone from the page, although the server rendered it and the browser hydrated it.
The same happens with Solid's development runtime (--conditions=development). Only the compile matters (<Show> kept as a component).
Screenshots or Videos
No response
Platform
- OS: macOS 26
- Browser: Chrome for Testing (Playwright 1.65.1,
channel: "chromium") - Version:
solid-js,@solidjs/web,@solidjs/signals2.0.3 andmain(99db9bce);@solidjs/compiler2.0.2; Node 26.13.1; Bun
Additional context
Bisect. The regression is in @solidjs/signals: solid-js/@solidjs/web rc.21 with @solidjs/signals rc.22 fails. With @solidjs/signals built from source under solid-js/@solidjs/web rc.21:
| signals build | #hydrated |
|---|---|
| dc33de68 | yes at ~120 ms |
| 08959165 (#4792) | yes at ~120 ms |
| b4647d52 | yes at ~120 ms |
| 9e02d02a (#4865) | never |
That is the commit #4965 bisected to. a4b40256 (#5085, for #5073) turns "never" into "only when the unrelated read answers", and #overview disappears meanwhile.
In a larger app on main. Our app has this shape (a workspace list → latest() → a scope every Studio read is keyed on, and several onSettled-mounted browser-only reads). With @solidjs/signals from main:
- the 2.0.3 symptoms (a hydrated list drawn twice,
aria-busythat never clears) are gone; - an engage dialog mounted by an
onSettledflag (<Show when={mounted()}><Loading><Show when={key()} keyed>) does not open within 30 s; Stale read from <Show>.is thrown into the root error boundary on every signed-in page. The read is a nested<Show when={box().rows$().length > 0 || box().unread$() > 0}>, inside<Show when={hydrated() && inbox}>{(box) => <Loading>…</Loading>}</Show>, wherehydratedis set inonSettled.
We traced the throw in the development build:
- The outer
<Show>opens in the flush that holds theonSettledwrites (a held transaction T). The inner<Show>'scondition valueis born in T. - When the workspace list's re-run answers, the inner
whenreadsrows$andunread$. These are sync memos whose verdict posture is inherited (page$→scope$→activeId$, which callslatest()), and none probes on its own. #4792's branch inread()forces arecomputeof each. They are pending on the browser-onlypage$, and the status propagation (notify…→list) seats the reader in the verdict lane L thatactiveId$started. - The inner
conditionthen readscondition value, and #4792's branch forces it too. That pass runs as L's (passLaneis L, not the flush's transaction). L's world does not hold T'shydrated = true, so the outer<Show>'s guard sees the committedfalseand throws. It throws again from the frame shortly after, still before T lands.
A standalone repro of the throw isn't included: every reduction of it lost the throw, while the hold above survived. The repro above is the same hold, seen from a block that isn't narrowed.
Workarounds. We found none that is plain Solid 2 code. Reading list() instead of latest(list) changes what a refresh of the list does (every untracked reader of the scope would throw while it re-asks). Making id probe on its own, #4965's workaround, is already the case here.
Related: #4965 (same first bad commit), #5073 / #5085 (the fix that turns "never" into this).
- 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