Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug?]: createAsync() or query() not working properly when using reactive params? #1691

Open
2 tasks done
michaelhaar opened this issue Dec 11, 2024 · 0 comments
Open
2 tasks done
Labels
bug Something isn't working

Comments

@michaelhaar
Copy link

michaelhaar commented Dec 11, 2024

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Current behavior 😯

(see Stackblitz example in repro section)

  • update the active/inactive filter by clicking the button multiple times with 5+ seconds breaks between clicks
  • Server function gets called multiple times. (see terminal logs)
  • (Server function is not called when clicking faster => Cache seems to be working)

Expected behavior 🤔

(see Stackblitz example in repro section)

  • Server function is called exactly 2 times regardless of the clicking speed?
  • Server function call is cached properly.

Steps to reproduce 🕹

Stackblitz Demo

Context 🔦

(I'm new to Solidjs and Solid-Start.)

I was following the data loading example from the latest (Beta) docs, which works fine:
https://docs.solidjs.com/solid-start/building-your-application/data-loading#data-loading-always-on-the-server

I tried adding some reactive parameters to the server function. Unfortunately the caching of the query() function isn't working as expected. Please find the Stackblitz example in the reproduction section!

(I was also able to reproduce this on my local machine in another project using the latest solid-start package 1.0.10)

Am I doing something wrong?

It would be great if you could also add a data loading with reactive params example to the docs?

Notes:
I think this issue caused by using a combination of createAsync+query+signals?

As far as I can tell this code is causing the issue:
https://github.com/solidjs/solid-router/blob/main/src/data/query.ts#L100-L112

(For some reason the function inside onCleanup(() => cached[4].count--); is called causing count to be zero and Date.now() - cached[0] < PRELOAD_TIMEOUT is causing this weird 5 second working caching behaviour)

PS:

@ryansolid and team: Thanks for creating this framework. Keep up the great work! I'll keep watching your streams on youtube.

Your environment 🌎

System:
  OS: macOS Ventura Version 13.5
  CPU: Apple M2 Pro
Binaries:
  Node: v20.11.0
  npm: 10.2.4
npmPackages:
  solid-start: 1.0.10
@michaelhaar michaelhaar added the bug Something isn't working label Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant