[2.0 / next] <Errored> recovery shows a pending memo's answer to an older input beside the new input

オープン
#4,592 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
20/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
javascript, typescript
領域
frontend

調査の方向性

Start with the two vitest cases in packages/web/test/, which run the same scenario with and without a Loading wrapper inside Errored. Run npx vitest run in packages/web to see the third frame fail with s=1a=10b=21. The fix belongs in how Errored decides it has recovered while memos a and b are still pending on the new input. Done when both tests pass and the frame shows error until a:1 resolves.

索引モデルが issue の本文から書いたものです。

説明

Describe the bug

a and b both ask by s. b's first question rejects, so <Errored> shows its fallback. Then s changes and both memos ask again. When b:1 resolves while a:1 is still out, <Errored> recovers and shows s=1a=10b=21. Here a=10 is the answer for s = 0, shown beside s=1. The frame becomes whole only when a:1 lands.

The same happens when the content is wrapped in a <Loading>.

Found by checking every frame of generated ryansolid/reactivescript programs, compiled onto Solid, against F-1.

Your Example Website or App

The vitest spec below (in packages/web/test/), on next @ 77be406ca.

Steps to Reproduce the Bug or Issue
import { render } from "@solidjs/web";
import { createMemo, createSignal, Errored, flush, Loading } from "solid-js";
import { expect, it } from "vitest";

const tick = async () => { for (let i = 0; i < 2; i++) { await new Promise(r => setTimeout(r, 0)); flush(); } };

async function run(boundary: "none" | "loading") {
  const flights = new Map<string, { resolve: (v: number) => void; reject: (e: Error) => void }>();
  const ask = (key: string) => new Promise<number>((resolve, reject) => flights.set(key, { resolve, reject }));
  const [s, setS] = createSignal(0);
  const el = document.createElement("div");
  const frames: string[] = [];
  const dispose = render(() => {
    const a = createMemo(() => ask("a:" + s()));
    const b = createMemo(() => ask("b:" + s()));
    const content = () => (<><p>s={s()}</p><p>a={a()}</p><p>b={b()}</p></>);
    return (
      <Errored fallback={<p>error</p>}>
        {boundary === "loading" ? <Loading fallback={<p>loading</p>}>{content()}</Loading> : content()}
      </Errored>
    );
  }, el);
  await tick();
  flights.get("a:0")!.resolve(10); await tick();
  flights.get("b:0")!.reject(new Error("boom")); await tick(); frames.push(el.textContent!);
  setS(1); flush(); await tick();                frames.push(el.textContent!);   // a:1 and b:1 asked
  flights.get("b:1")!.resolve(21); await tick();  frames.push(el.textContent!);   // b recovers; a:1 is still out
  flights.get("a:1")!.resolve(11); await tick();  frames.push(el.textContent!);
  dispose();
  return frames;
}

it("no boundary: <Errored> recovery does not show a pending memo's stale value beside its new input", async () => {
  expect(await run("none")).toEqual(["error", "error", "error", "s=1a=11b=21"]);
});

it("inside <Loading>: <Errored> recovery does not show a pending memo's stale value beside its new input", async () => {
  expect(await run("loading")).toEqual(["error", "error", "error", "s=1a=11b=21"]);
});

npx vitest run in packages/web. Both tests fail on the third frame, which is s=1a=10b=21 instead of error.

Expected behavior

The recovery waits until every memo in the content can answer the current s, or shows the content's own pending state. It never shows a's answer for an older s beside the new s (F-1, D-39).

Platform
  • OS: macOS
  • Browser: n/a (jsdom)
  • Version: solid-js 2.0.0-rc.20, next @ 77be406ca
主要言語
TypeScript
スター
36.2k
フォーク
1.1k
平均マージ
11時間 5分
マージ済み PR(30日)
475

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

solidjs/solid のほかの issue

solidjs/solid の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。