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

Stale read from <Show> under a transition #2046

Open
deluksic opened this issue Jan 23, 2024 · 5 comments
Open

Stale read from <Show> under a transition #2046

deluksic opened this issue Jan 23, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@deluksic
Copy link

deluksic commented Jan 23, 2024

Describe the bug

I'm encountering Stale read from <Show> while a transition is happening. I'm not sure exactly what the problem is, but I created a simple reproduction. I'm not reading the signal in a callback or in async code, which is why it is confusing to me.

Your Example Website or App

https://playground.solidjs.com/anonymous/bdbea778-bc1d-4508-963f-6683c38de3d5

Steps to Reproduce the Bug or Issue

  1. Click the counter and move the mouse at the same time

Expected behavior

I expect to see the tooltip instead (some text and coordinates). You can see it by holding the mouse still after click.

Workaround

Write the code without using the callback form of <Show>

@ryansolid ryansolid added the bug Something isn't working label Jan 23, 2024
@ryansolid
Copy link
Member

Yeah.. I see it.. interestingly only when the browser console is open but that suggests there is a timing issue here. Or more likely the internals of Show that do the check aren't concurrent safe. Thanks for reporting.

@deluksic
Copy link
Author

Can similar issues happen even if we don't use the callback form? I use this form a lot:

<Show when={condition()}>
  <Component prop={condition()!.something} />
</Show>

In this case, I assumed that <Component> would be unmounted before it had a chance to read from condition() and failing the .something. Reading the implementation of <Show>, I don't see much difference between callback vs non-cb forms, except for the arrow fn wrap and throw. I will try to create a test when I find time.

@ryansolid
Copy link
Member

You won't get the error because we don't do the checks. The reason we do is because someone could try to access the Signal inside like a timeout where it was no longer defined with a value which would mean TS lied. https://github.com/solidjs/solid/blob/main/packages/solid/src/render/flow.ts#L130C36-L130C45

Hmm.. interestingly it doesn't look like it is what expected. Reproducing this one will probably require me to run it in replay.

@mdynnl
Copy link
Contributor

mdynnl commented Jan 24, 2024

more controllable repro https://playground.solidjs.com/anonymous/e5a35370-6712-46cb-af2b-78d7eca848c0

edit:

  1. uncomment line 82
  2. click true under transition
  3. click inc: under foreground
  4. the same bug as this issue happens

the repro meant to show the interaction between the main reactivity system and the transition one in a controllable manner

@deluksic
Copy link
Author

more controllable repro https://playground.solidjs.com/anonymous/e5a35370-6712-46cb-af2b-78d7eca848c0

Can you please add steps for reproduction? I'm not sure what am I looking at. 😅

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

3 participants