Skip to content

[2.0 / next] An unowned memo with an isPending() reader skips its recompute: reads undefined after a landing, or keeps a stale value after an error recovers #4366

Closed

Description

@ryansolid

Found by the async app generator (packages/web/test/async-gen, branch claude/project-thread-bgafe5), minimized. Both shapes need module-level (unowned) memos and an isPending(m1) reader. Created inside the component, or without the isPending read, both are correct.

Shape 1: reads undefined after the first landing

let release;
const m0 = createMemo(() => new Promise(r => (release = r)));
const m1 = createMemo(() => m0() + 1);
render(() => (
  <Loading fallback="[L]">
    <Show when={m0()}><span>{String(isPending(m1))} {String(m1())}</span></Show>
  </Loading>
), el);
flush(); release(2); // after settling: <span>false NaN</span>, expected <span>false 3</span>

Shape 2: a stale value after the source recovers from an error

const [s0, set0] = createSignal(3);
const [s1, set1] = createSignal(3);
const m0 = createMemo(() => { const v = s1() + s0() + 1; if (v % 4 === 2) throw new Error("m0:" + v); return v; });
const m1 = createMemo(() => m0() + 1);
render(() => (
  <Errored fallback={e => `[E ${e()?.message}]`}>
    <Show when={latest(m0)} fallback="[F]"><span>{String(isPending(m1))} {String(m1())}</span></Show>
  </Errored>
), el);
set1(2); // [E m0:6], as expected
set0(2); // <span>false 8</span>, expected <span>false 6</span> (m0 = 5)

On next (1f558e5), both stay wrong after everything settles.

Activity

  1. ryansolid commented on Oct 28, 2026

    @ryansolid
    MemberAuthor

    Fixed on next by #4381 (4d8195d); it ships in the next RC.


    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions