{"record":{"id":"e0d9b61c45e14ac7","repo":"eyaltoledano/claude-task-master","slug":"maximum-recursion-depth-maxdepth-reached-for","errorCode":null,"errorMessage":"Maximum recursion depth (${maxDepth}) reached for task ${taskId}","messagePattern":"Maximum recursion depth \\((.+?)\\) reached for task (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"scripts/modules/utils.js","lineNumber":1553,"sourceCode":"\t\tif (typeof depId === 'string') {\n\t\t\t// Preserve string format for subtask IDs like \"1.2\"\n\t\t\tif (depId.includes('.')) {\n\t\t\t\treturn depId;\n\t\t\t}\n\t\t\t// Convert simple string numbers to numbers for consistency\n\t\t\tconst parsed = parseInt(depId, 10);\n\t\t\treturn isNaN(parsed) ? depId : parsed;\n\t\t}\n\t\treturn depId;\n\t}\n\n\t// Helper function for forward dependency traversal\n\tfunction findForwardDependencies(taskId, currentDepth = 0) {\n\t\t// Check depth limit\n\t\tif (currentDepth >= maxDepth) {\n\t\t\tconst warnMsg = `Maximum recursion depth (${maxDepth}) reached for task ${taskId}`;\n\t\t\tif (logger && typeof logger.warn === 'function') {\n\t\t\t\tlogger.warn(warnMsg);\n\t\t\t} else if (typeof log !== 'undefined' && log.warn) {\n\t\t\t\tlog.warn(warnMsg);\n\t\t\t} else {\n\t\t\t\tconsole.warn(warnMsg);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tif (processedIds.has(taskId)) {\n\t\t\treturn; // Avoid infinite loops\n\t\t}\n\t\tprocessedIds.add(taskId);\n\n\t\tconst task = allTasks.find((t) => t.id === taskId);\n\t\tif (!task || !Array.isArray(task.dependencies)) {\n\t\t\treturn;\n\t\t}\n","sourceCodeStart":1535,"sourceCodeEnd":1571,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/scripts/modules/utils.js#L1535-L1571","documentation":"findForwardDependencies in utils.js caps forward dependency traversal at maxDepth. When the recursion reaches that limit it emits this warning through the injected logger (falling back to log/console.warn) and stops expanding that path. It protects against runaway traversal of deep or cyclic dependency graphs.","triggerScenarios":"Calling the forward-dependency analysis (via analyzeTaskDependencies-style flows) on tasks whose 'dependsOn' chains are deeper than maxDepth.","commonSituations":"Very long dependency chains built over time; accidentally chained tasks (A depends on B depends on C ... dozens deep); default maxDepth too small for the project's graph size.","solutions":["Increase the maxDepth option passed to the dependency analysis to exceed your longest chain.","Refactor the task graph to flatten overly deep dependency chains.","Ignore the warning if truncation of very deep chains is acceptable.","Check for unintended cycles/long chains and remove bogus dependencies with task-master's dependency commands."],"exampleFix":"// before\nanalyzeDependencies(tasks, { maxDepth: 5 });\n// after\nanalyzeDependencies(tasks, { maxDepth: 20 });","handlingStrategy":"validation","validationCode":"function maxChainDepth(tasks) {\n  const map = new Map(tasks.map(t => [t.id, t.dependsOn || []]));\n  const seen = new Map();\n  const dfs = (id) => {\n    if (seen.has(id)) return seen.get(id);\n    seen.set(id, 0);\n    const d = 1 + Math.max(0, ...map.get(id).map(dfs));\n    seen.set(id, d);\n    return d;\n  };\n  return Math.max(0, ...tasks.map(t => dfs(t.id)));\n}\nif (maxChainDepth(tasks) >= maxDepth) throw new Error('Graph deeper than maxDepth');","typeGuard":null,"tryCatchPattern":"try {\n  const result = analyzeForwardDependencies(tasks, taskId, { maxDepth });\n  if (!result || result.length === 0) {\n    // possibly truncated by depth limit — rerun with larger maxDepth if needed\n  }\n} catch (e) { /* handle */ }","preventionTips":["Size maxDepth to the actual longest dependsOn chain in tasks.json.","Periodically audit and flatten deep dependency chains.","Detect and remove dependency cycles early.","Pass a structured logger so depth warnings are visible in your logs."],"tags":["recursion","dependencies","task-graph"],"backgroundTag":"recursion-depth-exceeded","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}