Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

latest() of an unread identity memo returns undefined when first read in the flush that re-asks its source

未关闭
#4,474 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
52/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
typescript
领域
frontend

调研方向

Start with the issue’s reproducer and trace the first read of latest(id) alongside isPending(id) when the Loading boundary mounts. Compare that case with creating the identity memo inside the mounted content, where the bug does not occur. Done when the reproducer no longer yields latest(id) === undefined after m has answered, while pending behavior remains correct.

由索引模型根据 Issue 内容生成。

描述

On next (e49b0c769), latest() can return undefined, which D-22 rules out ("It returns T, never undefined").

Setup:

  • m is an async memo, and id = createMemo(() => m()) is an identity memo created at the root. Nothing reads id yet.
  • m's first answer (2) lands in its own flush.
  • A write then re-asks m. In that same flush, a Loading boundary mounts content whose render effect reads latest(id) and isPending(id).

The effect's first run sees latest(id) === undefined and isPending(id) === true. Because m has been answered, latest(id) should be 2. If id is created inside the mounted content instead, the bug does not happen.

const asks: { v: number; resolve: (v: number) => void }[] = [];
const [s, setS] = createSignal(1);
const m = createMemo(() => { const v = 1 + s(); return new Promise<number>(resolve => asks.push({ v, resolve })); });
const id = createMemo(() => m());
const leaves: string[] = [];
createRoot(() => {
  const b = createLoadingBoundary(() => {
    const gate = createMemo(() => s() > 1);
    return createMemo(() => {
      if (!gate()) return "off";
      createRenderEffect(() => `l:${latest(id)} p:${isPending(id)}`, v => void leaves.push(v));
      return "on";
    });
  }, () => "fallback");
  createRenderEffect(() => { let v: any = b; while (typeof v === "function") v = v(); return v; }, () => {});
});
flush(); await task(); flush();
const first = asks.shift()!; first.resolve(first.v);
await task(); flush();          // m's answer (2) lands on its own
setS(2); await task(); flush(); // re-ask m and mount the content
// leaves: ["l:undefined p:true", ...]

Found while reviewing #4459; #4459 does not change it.

主要语言
TypeScript
星标
36.2k
派生
1.1k
平均合并
11 小时 48 分钟
30 天内合并 PR
441

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

solidjs/solid 的其他 Issue

查看 solidjs/solid 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。