Skip to content

Optimistic store update is hidden after a local derived-store write inside an action #3796

Description

@GabbeV

Describe the bug

On experimental build 6f77b1b, writing a client-only flag to a writable derived store inside an action prevents a subsequent optimistic store update from appearing while that action is pending.

The optimistic store wraps the derived store. The local write only sets failed = false; the optimistic write changes title to "New" and sets saving = true. A direct JSX binding keeps showing "Old" and saving: false until the action completes.

const [cards, setOptimistic] = createOptimisticStore(local);

const save = action(function* () {
  setLocal(draft => { draft[0].failed = false; });
  setOptimistic(draft => {
    draft[0].title = "New";
    draft[0].saving = true;
  });
  yield completion;
});

Removing the setLocal call makes the optimistic update appear. The reproduction uses a normal component and direct text binding, without For, Show, routing, or external data loading.

Your Example Website or App

https://s.olid.uk/id/d27cf7de-2cc1-45a8-9144-6868e307a78f

Steps to Reproduce the Bug or Issue

  1. Open the playground and click Run once.
  2. During the two-second simulated save, observe Old / saving: false instead of the optimistic values.
  3. After completion, the display changes to New / saving: false. The report records both states.
  4. Reload and remove the marked setLocal call to compare: the optimistic values appear during the save.

Expected behavior

The optimistic view should immediately show New / saving: true while the action is pending, including when the action first writes to its underlying local store. After completion, it should follow the authoritative source with the temporary saving flag removed.

Platform

  • OS: Linux (Ubuntu / WSL)
  • Browsers: Chromium 153.0.8010.12 and Firefox 155.0; identical results
  • Solid: solid-js, @solidjs/web, and @solidjs/signals from the Zulu 6f77b1b preview: updates mizulu/solid2#1 (comment)
  • Native compiler: @solidjs/compiler 2.0.0-rc.13

Additional context

The identical reproduction with published RC.13 is here: https://s.olid.uk/id/cf602874-eee9-400c-bd96-3022a77b7291

With the local flag write RC.13 6f77b1b
During the pending action New / saving: true Old / saving: false
After completion Old / saving: false New / saving: false

RC.13 shows the optimistic update correctly but suppresses the later source reconciliation discussed in #3733. The newer build reconciles correctly after completion, but loses the optimistic display while pending. Both playgrounds have Tailwind disabled.

Activity

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