Skip to content

2.0.0-rc.4 | optimistic store, read in an effect, changes the visible rendering. and has inconsistent value when logged and when rendered. #3141

Description

@mizulu

Describe the bug

block enabled

block enabled visible render

    // Renders
    //1,2,3
    //1,2,3,1111
    //3,2,1,5,666

block enabled logs

[2026-08-30T18:10:39.253Z] [log] Initial  [1,2]
[2026-08-30T18:10:39.254Z] [log] 1 yield:pre [1,2]

[2026-08-30T18:10:39.259Z] [log]             EFFECT: [1,2,3]
[2026-08-30T18:10:39.259Z] [log]             EFFECT: [1,2,3]
[2026-08-30T18:10:39.260Z] [log] 1 yield:post [1,2,3]
[2026-08-30T18:10:39.265Z] [log] start
[2026-08-30T18:10:39.267Z] [log] act 0
[2026-08-30T18:10:41.255Z] [log] 2  yield:pre [1,2,3]
[2026-08-30T18:10:41.258Z] [log] 2  yield:post [3,2,1]
[2026-08-30T18:10:42.261Z] [log] <<<<<<<<<<<
[2026-08-30T18:10:42.265Z] [log]             EFFECT: [3,2,1,1111]
[2026-08-30T18:10:43.266Z] [log] 3 mutation:pre [3,2,1]
[2026-08-30T18:10:43.270Z] [log] 3 mutation:post [3,2,1,5]
[2026-08-30T18:10:44.276Z] [log] 4 mutation:pre [3,2,1,5]
[2026-08-30T18:10:44.282Z] [log] 4 mutation:post [3,2,1,5,666]
[2026-08-30T18:10:45.280Z] [log] generator end
[2026-08-30T18:10:49.269Z] [log] <act 0
[2026-08-30T18:10:49.271Z] [log]             EFFECT: [3,2,1,5,666]
[2026-08-30T18:10:49.272Z] [log]             EFFECT: [3,2,1,5,666]

block disabled


block disabled visible renders

    // Renders
    //1,2,3
    //3,2,1
    //3,2,1,5,6

block disabled logs

[2026-08-30T18:14:27.326Z] [log] Initial  [1,2]
[2026-08-30T18:14:27.327Z] [log] 1 yield:pre [1,2]
[2026-08-30T18:14:27.328Z] [log] 1 yield:post [1,2,3]
[2026-08-30T18:14:27.330Z] [log] start
[2026-08-30T18:14:27.330Z] [log] act 0
[2026-08-30T18:14:29.320Z] [log] 2  yield:pre [1,2,3]
[2026-08-30T18:14:29.321Z] [log] 2  yield:post [3,2,1]
[2026-08-30T18:14:30.343Z] [log] <<<<<<<<<<<
[2026-08-30T18:14:31.324Z] [log] 3 mutation:pre [3,2,1]
[2026-08-30T18:14:31.324Z] [log] 3 mutation:post [3,2,1,5]
[2026-08-30T18:14:32.325Z] [log] 4 mutation:pre [3,2,1,5]
[2026-08-30T18:14:32.326Z] [log] 4 mutation:post [3,2,1,5,666]
[2026-08-30T18:14:33.338Z] [log] generator end
[2026-08-30T18:14:37.329Z] [log] <act 0

Your Example Website or App

https://s.olid.uk/id/ArFAHr5-Qv2P_vA6KctNiA

Steps to Reproduce the Bug or Issue

see reproduction code, disable and enable block by flipping the flag

Expected behavior

expecting consistent render, regardless if we have an effect or not

Screenshots or Videos

No response

Platform

.

Additional context

import { render } from '@solidjs/web';
import {  createOptimisticStore, Loading, action, createRenderEffect, deep } from 'solid-js';



var actCounter = 0
const act = action(function* (ms = 2000) {
  var i = actCounter++
  console.log("act", i)
  yield new Promise(r => setTimeout(r, ms))
  console.log("<act", i)
})
export default function App() {
  const [s, ss] = createOptimisticStore(async function* (s) {

    console.log("Initial ", JSON.stringify(s))       // offset:0 


    console.log("1 yield:pre", JSON.stringify(s))
    yield [1, 2, 3]
    console.log("1 yield:post", JSON.stringify(s))

    await new Promise(r => setTimeout(r, 2000));
    console.log("2  yield:pre", JSON.stringify(s)) // offset: 2000
    yield [3, 2, 1]
    console.log("2  yield:post", JSON.stringify(s))



    await new Promise(r => setTimeout(r, 2000));  // offset: 4000
    console.log("3 mutation:pre", (JSON.stringify(s)))
    s.push(5)  // not going to render 
    console.log("3 mutation:post", (JSON.stringify(s)))

    await new Promise(r => setTimeout(r, 1000)); // offset: 5000

    console.log("4 mutation:pre", (JSON.stringify(s)))
    s.push(666)
    console.log("4 mutation:post", (JSON.stringify(s)))

    await new Promise(r => setTimeout(r, 1000)); // offset: 6000

    console.log("generator end")
  }, [1, 2] )


  setTimeout(() => {
    console.log("start")
    act(10000);  // 10s transition 

    setTimeout(() => {
      console.log("<<<<<<<<<<<") // this will run prior to "3 mutation:pre" between the 2000..4000 offset 
      ss(draft => draft.push(1111))
    }, 3000)  // offset: 3000
  }, 0)


  // The application renders differently depends if we run this block or not.
  const  enableBlock = true
  if (enableBlock) {
    // Renders: 
    //1,2,3
    //1,2,3,1111
    //3,2,1,5,666
    createRenderEffect(() => {
      return deep(s)

    }, (s) => {
      console.log("            EFFECT:", JSON.stringify(s))
    })

  } else {
    // Renders
    //1,2,3
    //3,2,1
    //3,2,1,5,6
  }


  return (
    <div class="p-2">
      <Loading>
        {JSON.stringify(s)}
      </Loading>
    </div>
  );
}


if (typeof document !== 'undefined') {
  render(() => <App />, document.getElementById('root')!);
}

block disabled playground
block enabled playground

The optimistic write is sometimes visible sometimes it does not depends on our conditional effect read.

also the rendering and the render effect do not align in values for example

when enabled the rendered dom shows:
1,2,3,1111

but the render effect logs:
3,2,1,1111

if not a mistake in reproduction this might be considered an additional symptom

may be related in part or in full to the root cause of the issue in

#3123

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