amark/gun · error · Error

Infinite loop in \:var dependencies

Error message

Infinite loop in \:var dependencies

What it means

Loop-detector in updateVar(): every non-initial update of a \:var increments infinityCheck for that name; if the counter exceeds loopLimit (0) within one propagation cascade, the variable is being updated repeatedly by its own dependency cycle, so it throws. Before throwing it logs the hot variables and renders the reactive graph in the editor to help locate the cycle.

Source

Thrown at lib/wave.js:337

      }
    }
    if (typeof name !== 'string') { // symbol ~ react function
      return;
    }
    if (values.get(name) === val && typeof val !== 'object') {
      return;
    }
    if (infinityCheck.get(name) > loopLimit) {
      infinityCheck.forEach((k) => {
        return edide.logProd(k);
      });
      edide.logProd(name);
      if ((ref = edide.editorModule) != null) {
        if (typeof ref.reactiveGraph === "function") {
          ref.reactiveGraph();
        }
      }
      throw Error("Infinite loop in \:var dependencies");
    }
    if (debugging) {
      edide.logProd(`updating ${name}`);
    }
    values.set(name, val);
    if (!inInitCall) {
      infinityCheck.set(name, (infinityCheck.get(name) || 0) + 1);
      if ((ref1 = dependees.get(name)) != null) {
        ref1.forEach((depName) => {
          return updateVar(depName);
        });
      }
      infinityCheck.delete(name);
    }
    return val;
  };

  currentReact = [];

View on GitHub (pinned to 552227599d)

Solutions

  1. Break the dependency cycle: find variables whose setters write back to variables they read from and remove the circular write
  2. Add a condition or staleness check in the setter so it stops re-writing the same value (updateVar already skips identical primitive values)
  3. Temporarily raise loopLimit to confirm the cascade converges rather than loops infinitely
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at lib/wave.js:337 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of amark/gun@552227599d (2026-09-02). Data as JSON: /api/errors/c216bf29c020a8ed. Report an issue: GitHub.