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

[Full-stack Signals] Cannot update a signal that you're not subscribed to #2701

Open
Legioth opened this issue Sep 4, 2024 · 2 comments
Open
Labels
bug Something isn't working hilla Issues related to Hilla

Comments

@Legioth
Copy link
Member

Legioth commented Sep 4, 2024

Describe the bug

Trying to manipulate a signal for which you don't have an open subscription will lead to an exception like java.lang.IllegalStateException: Signal not found for client signal: MXbPB5IqFiJzkzI1v7W0m.

Aside from offline cases that are described in #2653, this does also happen if you want to e.g. increment a counter already before it has been shown. This might be the case if you want to count how many times a view has been opened or if you build a poll where you only see the results after you have submitted your own choice.

Expected-behavior

Expected that signal operations can be submitted even without an active subscription as long as the access control check passes for the server-side service method. This means that the service method would have to be invoked again for each operation when there's no subscription but that should be fine since we are anyways expecting such methods to be deterministic.

Reproduction

const counter = StatsService.counter();

export default function Counter() {
    const subscribe = useSignal(false);
    
    return <VerticalLayout>
        <Button onClick={() => counter.increment()}>Increment</Button>
        <Checkbox checked={subscribe.value} onCheckedChanged={(event) => subscribe.value = event.detail.value} label="Subscribed" />
        {subscribe.value ? <>Live value: {counter}</> : <>Peeked value: {counter.peek()} </>}
    </VerticalLayout>
}

System Info

Hilla 24.5.0.alpha13

@Legioth Legioth added bug Something isn't working hilla Issues related to Hilla labels Sep 4, 2024
@Legioth Legioth changed the title Cannot update a signal that you're not subscribed to [Full-stack Signals] Cannot update a signal that you're not subscribed to Sep 11, 2024
@platosha
Copy link
Contributor

Note: we could solve this by creating a temporary subscription for processing any preliminary operations. However, we would also need to close such subscriptions immediately to avoid memory leaks.

@platosha
Copy link
Contributor

Let's get back to this after having thenable operations, see #2712

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

2 participants