Skip to content

2.0.0-rc.7 | flush in action unexpected behavior fixed in 3a5fe8c by not allowing flush in action  #3333

Description

@mizulu

Describe the bug

import { render } from '@solidjs/web';
import { action, createOptimistic, createSignal, flush } from "solid-js";



export default function App() {
  const [signal, setSignal] = createSignal(0);
  const [optimisticValue, setOptimisticValue] = createOptimistic(signal);

 /**
  *  Click "Run once"
    actual: 
      logs:
         0 0 
         0 0 

    expected:
      logs:  
         0 0 
         0 1

  signal used in an optimistic signal source, prevents flushing of the signal 
  in an "action"
  */

  const run = action(function* () {
    console.log(optimisticValue(), signal())
    setSignal(1);
    flush()
    console.log(optimisticValue(), signal())
  });



  return (
    <main>
      <button onClick={run}>Run once</button>
      <p>Value: {optimisticValue()}</p>
    </main>
  );
}

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

Your Example Website or App

https://s.olid.uk/id/ILIMhE-cRXeISRjlRaxXwQ

Steps to Reproduce the Bug or Issue

see playground

Expected behavior

probably not what we are getting.

Screenshots or Videos

No response

Platform

.

Additional context

issue might share common root cause with #3330
or not.

https://s.olid.uk/id/RmxCWTx3RXmTFMsAb5b58g

edit: verdict is that the bug is allowing flush in action, and it is expected that no flush should be allowed in an action.
as shown in the followup comment below

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