You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Edge case: infinite loop/out of memory in certain situations #123
In some scenarios computeds can get stuck in an infinite loop and/or cause out of memory.
Here is a minimal program that will get stuck:
import{computed,signal}from"alien-signals";constfieldA=signal(false);constfieldB=signal(false);consta=computed(()=>{returnb()!==true ? fieldA() : null;});constb=computed((): boolean|null=>{returna()!==true ? fieldB() : null;});console.log("a",a());// falseconsole.log("b",b());// falsefieldA(true);console.log("Field A changed");// BREAKS HERE when trying to get aconsole.log("a",a());console.log("b",b());
What I would expect:
At least that it would not get stuck in an infinite loop.
But I am not sure about the result.
I am not sure if this should be part of the core of alien-signals as the result may be a bit ambigous.
This is the other side of the performance trade-off, not really an edge case.
The runtime assumes computed dependencies form a DAG and does not perform cycle detection in the hot path. As a result, cyclic computed graphs are unsupported and may not terminate. Ideally this should be reported in development mode, while production treats it as an invariant.
Activity
volynetstyle commentedon Jun 10, 2026
This is the other side of the performance trade-off, not really an edge case.
The runtime assumes computed dependencies form a DAG and does not perform cycle detection in the hot path. As a result, cyclic computed graphs are unsupported and may not terminate. Ideally this should be reported in development mode, while production treats it as an invariant.