solid icon indicating copy to clipboard operation
solid copied to clipboard

solid / start : `createAsync`/`createResource` mixes results when run server side, when component has "unstable" execution. due to secondary rerun of the suspended component.

Open mizulu opened this issue 5 months ago • 4 comments

Describe the bug

createAsync/createResource mixes results when run server side, when component has "unstable" execution. due to secondary rerun of the suspended component. and incorrect mapping.

Your Example Website or App

https://stackblitz.com/edit/github-52yqwfhu-kryvpmtc?file=src%2Froutes%2Fx.tsx,src%2Froutes%2Fabout.tsx

Steps to Reproduce the Bug or Issue

  1. go directly to the /about in the browser not via the link
  2. observe the logs

Expected behavior

  if (shouldRedirect()) {
    console.log('LATER');
    console.log('A:', aAsy()); // expected "A: a"  actual "A: b"
    console.log('B:', bAsy()); // expected "B: b"  actual "B: a"
  } else {
    console.log('INITIAL');

    console.log('A:', aAsy()); // should be undefined
    console.log('B:', bAsy()); // should be undefined
  }

Screenshots or Videos

https://github.com/user-attachments/assets/d9290ce8-3da1-412c-8370-4c4ba3d9b655

Platform

online playground

Additional context

  if (shouldRedirect()) {
    // later
    // if we flip back the order it will become stable again
    aAsy = createAsync(() => a());
    bAsy = createAsync(() => b());
    // bAsy = createAsync(() => b());
    // aAsy = createAsync(() => a());
  } else {
    // initial
    bAsy = createAsync(() => b());
    aAsy = createAsync(() => a());
  }

solid re runs the suspended component on the 2nd run it tries to match the results based on the original (initial) order of requests.

because we flip the createAsync order on the "later" phase the results are matched incorrectly.

mizulu avatar Jul 25 '25 18:07 mizulu

Image Image

mizulu avatar Jul 25 '25 18:07 mizulu

this is the playground with the stable example https://stackblitz.com/edit/github-52yqwfhu-whw2w4gw?file=src%2Froutes%2Fabout.tsx

mizulu avatar Jul 25 '25 18:07 mizulu

I Created a simplified repro to show the issue and its implications

https://stackblitz.com/edit/github-52yqwfhu-ak1xbhv6?file=src%2Froutes%2Fabout.tsx

https://github.com/user-attachments/assets/48901a58-bb57-4f24-a90b-3cad376cf468

cc: @ryansolid

is this something that is documented or need to be documented ? what is your take on the issue can it be fixed in solid 1.x

is it going to be a problem in solid 2.x ?

mizulu avatar Jul 26 '25 18:07 mizulu

Yeah it should be documented. Because of the way we do re-renders during SSR it's the only primitive that suffers from "hook" rules and only during SSR. In 2.0 the pull-based system won't have this problem.

Maybe we move the issue there and make it a documentation issue because we won't be able to fix this in 1.0 design.

ryansolid avatar Jul 29 '25 22:07 ryansolid