Lowered `<Show>` (`lowerShow`, the production default) shows a different screen than the `<Show>` component while a write is held
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 25/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 停滞
- 技術スタック
- javascript, typescript
調査の方向性
Start by reading the lower_show.rs lowering mentioned in the issue and the behavior added in #4730, then compare the generated ternary with the Show component under the supplied universal renderer repro. Trace how both forms interact with Loading, latest, and a pending read; the linked pull request #5099 is already open. Done means both lowerShow settings produce the expected screens in both repro cases, with the branch held until its read resolves.
索引モデルが issue の本文から書いたものです。
説明
The same component renders a different screen depending on whether @solidjs/compiler lowers <Show> to a ternary (lowerShow: true, the default when dev is off, added in #4730) or keeps the component (lowerShow: false, the dev default). The difference shows up while a write is held by a pending async read under <Loading>, and it goes in both directions:
- With a plain
<Show when={s() > 0}>and a display-ahead<Show when={latest(() => s()) > 0}>side by side, the lowered build leaves alatest(() => s())text at the old value. The component build shows the new value. - With only the display-ahead
<Show>, the component build attaches the branch with its hole empty. The lowered build keeps the fallback.
So a production build and a dev build of the same app show different screens for the same steps, and neither one gives the screen SCENARIOS.md S-46 rules on in both cases.
Found at: solid-js 2.0.3, @solidjs/signals 2.0.3, @solidjs/universal 2.0.3, @solidjs/compiler 2.0.2 (the published latest), and next c74567ab1. It shows the same way under the development and the production export conditions. I did not bisect it, and I only ran it on the universal renderer, not @solidjs/web with a DOM.
How it was found: running a ReactiveScript program's Solid view (plain createSignal/createMemo/<Show>/<Loading> code, compiled by @solidjs/compiler) against the program's own compiled output, on the same renderer and the same steps. Across 800 generated programs and 3,168 runs, 20 programs showed a different screen. All 20 matched again when the view was compiled with lowerShow: false. The repro below is the reduced shape, rebuilt in plain Solid.
Repro
Save as repro.mjs in a folder with solid-js, @solidjs/compiler and @solidjs/universal installed, then run node --conditions=browser --conditions=development repro.mjs. It compiles one component twice, with lowerShow off and on, and runs both on the same runtime. a asks a request that never answers, so setS(2), which would show a, is held.
import { transform } from "@solidjs/compiler";
import { writeFileSync } from "node:fs";
import { fileURLToPath, pathToFileURL } from "node:url";
import { flush } from "solid-js";
// A minimal string-tree renderer, as a module the compiled JSX imports.
const renderer = fileURLToPath(new URL("./renderer.mjs", import.meta.url));
writeFileSync(renderer, `import { createRenderer } from "@solidjs/universal";
export { Show, Loading, Errored } from "solid-js";
const R = createRenderer({
createElement: (tag) => ({ tag, children: [] }),
createTextNode: (text) => ({ text }),
replaceText: (n, v) => { n.text = v; },
isTextNode: (n) => "text" in n,
setProperty() {},
getParentNode: (n) => n.parent,
getFirstChild: (n) => n.children?.[0],
getNextSibling: (n) => n.parent && n.parent.children[n.parent.children.indexOf(n) + 1],
insertNode(p, n, anchor) {
if (n.parent) n.parent.children.splice(n.parent.children.indexOf(n), 1);
const i = anchor ? p.children.indexOf(anchor) : -1;
i < 0 ? p.children.push(n) : p.children.splice(i, 0, n);
n.parent = p;
},
removeNode(p, n) { p.children.splice(p.children.indexOf(n), 1); n.parent = undefined; },
});
export const { render, effect, memo, createComponent, createElement, createTextNode, insertNode, insert, spread, setProp, mergeProps } = R;
export const text = (n) => ("text" in n ? String(n.text) : n.children.map(text).join(""));
`);
const app = (plain, gate) => `
import { createSignal, createMemo, latest, Loading, Errored, Show } from "solid-js";
import { render, text } from ${JSON.stringify(renderer)};
export function run() {
const pending = () => new Promise(() => {});
const root = { tag: "root", children: [] };
let setS;
function App() {
const [s, set] = createSignal(1);
setS = set;
const a = createMemo(() => pending(s()));
return (
<Errored fallback={<p>error</p>}>
<Loading fallback={<p>loading</p>}>
{<>
${plain ? `<Show when={s() > 0} fallback={<p>[plain off] </p>}><p>[plain on {a()}] </p></Show>` : ""}
<p>[latest {latest(() => s())}] </p>
${gate ? `<Show when={latest(() => s()) > 0} fallback={<p>[gate off]</p>}><p>[gate on {a()}]</p></Show>` : ""}
</>}
</Loading>
</Errored>
);
}
render(() => <App />, root);
return { screen: () => text(root), setS };
}`;
const settle = async () => { for (let i = 0; i < 3; i++) { await new Promise((r) => setTimeout(r, 0)); flush(); } };
for (const [name, plain, gate] of [["both", true, true], ["gate only", false, true]]) {
for (const lowerShow of [false, true]) {
const code = transform(app(plain, gate), { filename: "app.jsx", generate: "universal", moduleName: renderer, lowerShow }).code;
const file = fileURLToPath(new URL(`./app-${name.replace(" ", "-")}-${lowerShow}.mjs`, import.meta.url));
writeFileSync(file, code);
const a = (await import(pathToFileURL(file).href)).run();
await settle();
a.setS(0); await settle();
const before = a.screen();
a.setS(2); await settle();
console.log(`${name.padEnd(9)} lowerShow: ${String(lowerShow).padEnd(5)} after setS(0): ${JSON.stringify(before).padEnd(36)} after setS(2): ${JSON.stringify(a.screen())}`);
}
}
Observed
both lowerShow: false after setS(0): "[plain off] [latest 0] [gate off]" after setS(2): "[plain off] [latest 2] [gate off]"
both lowerShow: true after setS(0): "[plain off] [latest 0] [gate off]" after setS(2): "[plain off] [latest 0] [gate off]"
gate only lowerShow: false after setS(0): "[latest 0] [gate off]" after setS(2): "[latest 2] [gate on ]"
gate only lowerShow: true after setS(0): "[latest 0] [gate off]" after setS(2): "[latest 2] [gate off]"
Each case gives the same screen when it runs alone in its own process.
Expected
The same screen with lowerShow on and off, and in both cases the screen S-46 case 1 rules on: the display-ahead reader shows the new value, and the branch it opens is born held, so its fallback stays until a lands.
- both:
[plain off] [latest 2] [gate off]. The component build shows this. The lowered build leaves[latest 0], so thelatestreader does not read ahead. - gate only:
[latest 2] [gate off]. The lowered build shows this. The component build shows[gate on ], the branch attached with its hole empty, which S-46 lists as forbidden ("F-2: never an empty slot").
Needed to reproduce
- The plain
<Show when={s() > 0}>and its pending content decide the first case. Without it (the "gate only" case), the lowered build is the one that is right. - The
<Show>s sit in a fragment that is the only child of<Loading>. That is a positionlower_show.rslowers. As siblings directly under<Loading>, neither build lowers them, and both show thelowerShow: falsescreens, including[gate on ]in the "gate only" case. So the empty slot does not need the fragment.
Related
- #4730 added the lowering. Its doc comment describes the ternary as "what
<Show>does for JSX children withoutkeyed". - #4806 (closed) was the display-ahead
<Show>attaching early for text, fragment and function children. The "gate only" component row is the same symptom with an element child under<Loading>, which that issue lists as correct. - #4936 (closed) was a lowered
<Show>re-reading itswhen. It is a different problem.
I have not traced where the two forms part in the runtime.
- 主要言語
- TypeScript
- スター
- 37k
- フォーク
- 1.2k
- 平均マージ
- 8時間 43分
- マージ済み PR(30日)
- 365
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
solidjs/solid のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1〜3時間 初心者へのやさしさ 88/100
メンテナーはふだん 1 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
メンテナーはふだん 1 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 38/100
メンテナーはふだん 1 日以内に返信
-
[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 handles対応中かも @MilindChatrabhuji が 2 日前に担当しました。 オープン
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
メンテナーはふだん 1 日以内に返信
似ている issue
-
agentscan:mixed-signals pending triage
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
vueuse/vueuse#5737 · コメント 2 件 ·
メンテナーはふだん 9 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
Marker-Inc-Korea/AutoRAG#2288 ·
メンテナーはふだん 1 日以内に返信
-
Resources: New templates of Guangzhou Metro Line 13対応中かも @rmt-svc が今日担当しました。 オープンresources
難易度 1/5 1時間未満 初心者へのやさしさ 76/100
railmapgen/rmg-templates#2730 ·
メンテナーはふだん 1 日以内に返信
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
web
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信