Skip to content

AK0030

Circular dependency detected in computed signal

What happened

A computed() signal reads its own value, either directly or through a chain of other computed signals that eventually circle back to it. This creates an infinite loop that AkashJS detects and halts.

How to fix

Restructure your computed signals to break the cycle. If two values depend on each other, extract the shared logic into a single computed or use a plain signal that you update manually.

Example

ts
// Bad — circular: a reads b, b reads a
const a = computed(() => b() + 1);
const b = computed(() => a() + 1);

// Good — break the cycle with a source signal
const source = signal(0);
const a = computed(() => source() + 1);
const b = computed(() => source() + 2);

Released under the MIT License.