hilla
hilla copied to clipboard
ListSignal insertLast fails if used before reading value
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
Sounds like a duplicate of https://github.com/vaadin/hilla/issues/2701 which was fixed last week but the fix is not yet in the latest alpha release.
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.
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.
We can close this as duplicate.