Skip to content

Writes that net under a custom equals still pend (D-8) #4483

Closed

Description

@ryansolid

On next (ab3d2ad), writes count as netted only by identity: a signal's staging counts as netted only when _pendingValue === _value. A signal with a custom comparator can net back to a value the comparator calls equal to the committed one, and that staging still counts as a proposal. The memo over it goes pending. D-8 says writes that net to the committed value make no proposal.

const one = { k: 1 };
const [s, setS] = createSignal(one, { equals: (a, b) => a.k === b.k });
const m0 = createMemo(() => {
  const v = s().k + 1;
  if (v % 4 === 2) throw new Error(`m0:${v}`);
  return v;
});
createRenderEffect(() => isPending(m0), v => seen.push(v));
flush();
const act = action(function* () {
  setS({ k: 1 }); // equal to the committed value by the comparator, not by identity
  yield new Promise(() => {});
});
setS({ k: 2 });
act();
// await a task, then flush
// seen: [false, true]   expected: [false]

Writing back the committed object itself (setS(one)) nets, and seen stays [false].

One possible fix: at write time, when the comparator says the new staging equals the committed value, store the committed object as the staging. The existing identity test then sees the writes as netted.

Found while reviewing #4472.

Activity

  1. ryansolid commented on Oct 30, 2026

    @ryansolid
    MemberAuthor

    Fixed on next by #4488 (6af149e); 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