Skip to content

2.0.0-beta.28: <Show> when={isPending || !!promise} or when={promise} causes stale reads #2963

Description

@dangkyokhoang

Describe the bug

Might be relevant issues so I create 1 tracking issue:

1: <Show when={isPending(state) || !!state().promise}> inside a <> fragment — Shows evaluate with stale state: mutually exclusive conditions both become true, and resolved data doesn't show until next submit. Works correctly with <div> or <Show when={isPending(() => !!state().promise)}>.
2+3: <Show when={state().promise}> — two bugs: (1) Show's memo is async-shape aware, so receiving a thenable creates an implicit transition that defers signal updates — promise is invisible during loading. (2) Second click causes stale accessor error that halts the entire reactive system.

On the 2+3, though I might be expected to write <Show when={!!state().promise}> instead, I think this should still be considered a bug. The mechanism of this issue might be that <Show when> wraps promise in a memo and the rest is related to #2802.

Because of how the createMemo integrates deeply with the transitions and the reactive system, which causes it to have some unexpected behaviors or "rules" users should be aware of, I think solid should not try to implicitly wrap when value in a memo. And as you commented in #2957, it seems solid by default might heuristically decide to wrap other component props in memos as well. I think this work (wrapping things in memos) should be on the user, not the framework. Less burden on the framework, and more predictable behavior for users.

Your Example Website or App

https://stackblitz.com/edit/nitrojs-nitro-azkekile?file=src%2FApp.tsx

Steps to Reproduce the Bug or Issue

  1. Go to the link above
  2. Open example page
  3. Select issue 1 or 2
  4. Click submit button
  5. Wait and click submit button again

Expected behavior

Should be no issue.

Screenshots or Videos

No response

Platform

  • OS: [e.g. macOS, Windows, Linux]
  • Browser: [e.g. Chrome, Safari, Firefox]
  • Version: [e.g. 91.1]

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