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

ListSignal insertLast fails if used before reading value #2852

Open
krissvaa opened this issue Oct 21, 2024 · 4 comments
Open

ListSignal insertLast fails if used before reading value #2852

krissvaa opened this issue Oct 21, 2024 · 4 comments
Labels
bug Something isn't working hilla Issues related to Hilla

Comments

@krissvaa
Copy link
Contributor

krissvaa commented Oct 21, 2024

Describe the bug

Trying to insert value into list signal before reading the value for the first time always fails with an error:

Caused by: java.lang.IllegalStateException: Signal not found for client signal: 7r5ynGjRRkDNyqwdhU23X
at com.vaadin.hilla.signals.handler.SignalsHandler.update(SignalsHandler.java:94)

Expected-behavior

Insert should work everytime

Workaround is to read the list signal value before inserting any values

effect(() => { 
    listSignal.value;
});

Reproduction

Project to reproduce: my-app-listsignal.zip

System Info

Hilla: 24.6.0.alpha1

@krissvaa krissvaa added bug Something isn't working hilla Issues related to Hilla labels Oct 21, 2024
@Legioth
Copy link
Member

Legioth commented Oct 21, 2024

Sounds like a duplicate of #2701 which was fixed last week but the fix is not yet in the latest alpha release.

@taefi
Copy link
Contributor

taefi commented Oct 21, 2024

There could be a small problem that needs investigation:
The fix we merged last week might still not work for a specific case:
If a ListSignal is conditionally rendered, e.g. checking the items.length === 0 to show a placeholder message such as "no items yet..." and the user does not interact with it, the signal may never subscribe to receive the updates that triggers renders.

@Legioth
Copy link
Member

Legioth commented Oct 21, 2024

Why does items have a length property? Should work properly if you do items.value.length since you're then actually reading the signal's value. As we discussed at some point previously, we should prefer to "force" the developer to use .value to make the signal relationship clear rather than providing shorthands.

@taefi
Copy link
Contributor

taefi commented Oct 21, 2024

We can close this as duplicate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working hilla Issues related to Hilla
Projects
None yet
Development

No branches or pull requests

3 participants