Skip to content

[2.0 / next] A guess on a second createOptimistic made while another action's refresh is in flight doesn't show (#4629, other source) #4666

Closed

Description

@ryansolid

On next @ b656418.

This is #4629's shape, but the second guess goes into a different createOptimistic. #4637 fixed the case where both guesses go into the same log; that case passes here. With a second log, the guess is held: it doesn't show while its own action is out. It is still hidden after that action is accepted, and appears only once every refresh has landed.

const server = createMemo(() => ask("fetch").then(() => serverRows.map(r => ({ ...r }))));
const [assignTruth] = createSignal(() => [] as number[]);
const [assigning, guessAssign] = createOptimistic(() => assignTruth());
const [closeTruth] = createSignal(() => [] as number[]);
const [closing, guessClose] = createOptimistic(() => closeTruth());
const shown = createMemo(() => server()
  .filter(r => !closing().includes(r.id))
  .map(r => `#${r.id}(${assigning().includes(r.id) ? "guest" : r.who ?? "-"})`).join(" "));
createRenderEffect(() => shown(), v => frames.push(v));

const assign = action(function* (id) { guessAssign(xs => [...xs, id]); yield ask(`assign:${id}`); /* server updates */ refresh(server); });
const close  = action(function* (id) { guessClose(xs => [...xs, id]);  yield ask(`close:${id}`);  /* server updates */ refresh(server); });

Steps: land fetch with rows #1 and #3. Call assign(3) and land assign:3; its refresh(server) is now in flight. Then call close(3).

step frame expected
assign #3 guessed #1(-) #3(guest) ✓
assign accepted, its refresh in flight #1(-) #3(guest) ✓
close #3 guessed #1(-) #3(guest) #1(-)
close accepted (its refresh in flight too) #1(-) #3(guest) #1(-)
every refresh landed #1(-) ✓

The same steps with the close guess written into assigning (same log) show #1(-) at once.

How we found it: it is the most common remaining fuzzer hole in AI-written ReactiveScript apps on our eval's issue desk. Seed 5, "closed row shown", appears in 4 of 12 apps on b656418. Those apps keep one guess log per action kind over a refreshed list.

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