{"record":{"id":"c216bf29c020a8ed","repo":"amark/gun","slug":"infinite-loop-in-var-dependencies","errorCode":null,"errorMessage":"Infinite loop in \\:var dependencies","messagePattern":"Infinite loop in \\\\:var dependencies","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"lib/wave.js","lineNumber":337,"sourceCode":"      }\n    }\n    if (typeof name !== 'string') { // symbol ~ react function\n      return;\n    }\n    if (values.get(name) === val && typeof val !== 'object') {\n      return;\n    }\n    if (infinityCheck.get(name) > loopLimit) {\n      infinityCheck.forEach((k) => {\n        return edide.logProd(k);\n      });\n      edide.logProd(name);\n      if ((ref = edide.editorModule) != null) {\n        if (typeof ref.reactiveGraph === \"function\") {\n          ref.reactiveGraph();\n        }\n      }\n      throw Error(\"Infinite loop in \\:var dependencies\");\n    }\n    if (debugging) {\n      edide.logProd(`updating ${name}`);\n    }\n    values.set(name, val);\n    if (!inInitCall) {\n      infinityCheck.set(name, (infinityCheck.get(name) || 0) + 1);\n      if ((ref1 = dependees.get(name)) != null) {\n        ref1.forEach((depName) => {\n          return updateVar(depName);\n        });\n      }\n      infinityCheck.delete(name);\n    }\n    return val;\n  };\n\n  currentReact = [];","sourceCodeStart":319,"sourceCodeEnd":355,"githubUrl":"https://github.com/amark/gun/blob/552227599d47ba0493824b7fcf8a00c8cd6404ba/lib/wave.js#L319-L355","documentation":"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.","triggerScenarios":"Thrown at lib/wave.js:337 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Break the dependency cycle: find variables whose setters write back to variables they read from and remove the circular write","Add a condition or staleness check in the setter so it stops re-writing the same value (updateVar already skips identical primitive values)","Temporarily raise loopLimit to confirm the cascade converges rather than loops infinitely"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"552227599d47ba0493824b7fcf8a00c8cd6404ba","analyzedAt":"2026-09-02T18:40:58.370Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T21:17:11.164Z"}