eyaltoledano/claude-task-master · warning

Maximum recursion depth (${maxDepth}) reached for task ${tas

Error message

Maximum recursion depth (${maxDepth}) reached for task ${taskId}

What it means

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.

Source

Thrown at scripts/modules/utils.js:1553

		if (typeof depId === 'string') {
			// Preserve string format for subtask IDs like "1.2"
			if (depId.includes('.')) {
				return depId;
			}
			// Convert simple string numbers to numbers for consistency
			const parsed = parseInt(depId, 10);
			return isNaN(parsed) ? depId : parsed;
		}
		return depId;
	}

	// Helper function for forward dependency traversal
	function findForwardDependencies(taskId, currentDepth = 0) {
		// Check depth limit
		if (currentDepth >= maxDepth) {
			const warnMsg = `Maximum recursion depth (${maxDepth}) reached for task ${taskId}`;
			if (logger && typeof logger.warn === 'function') {
				logger.warn(warnMsg);
			} else if (typeof log !== 'undefined' && log.warn) {
				log.warn(warnMsg);
			} else {
				console.warn(warnMsg);
			}
			return;
		}

		if (processedIds.has(taskId)) {
			return; // Avoid infinite loops
		}
		processedIds.add(taskId);

		const task = allTasks.find((t) => t.id === taskId);
		if (!task || !Array.isArray(task.dependencies)) {
			return;
		}

View on GitHub (pinned to c0c98d367c)

Solutions

  1. Increase the maxDepth option passed to the dependency analysis to exceed your longest chain.
  2. Refactor the task graph to flatten overly deep dependency chains.
  3. Ignore the warning if truncation of very deep chains is acceptable.
  4. Check for unintended cycles/long chains and remove bogus dependencies with task-master's dependency commands.

Example fix

// before
analyzeDependencies(tasks, { maxDepth: 5 });
// after
analyzeDependencies(tasks, { maxDepth: 20 });
Defensive patterns

Strategy: validation

Validate before calling

function maxChainDepth(tasks) {
  const map = new Map(tasks.map(t => [t.id, t.dependsOn || []]));
  const seen = new Map();
  const dfs = (id) => {
    if (seen.has(id)) return seen.get(id);
    seen.set(id, 0);
    const d = 1 + Math.max(0, ...map.get(id).map(dfs));
    seen.set(id, d);
    return d;
  };
  return Math.max(0, ...tasks.map(t => dfs(t.id)));
}
if (maxChainDepth(tasks) >= maxDepth) throw new Error('Graph deeper than maxDepth');

Try / catch

try {
  const result = analyzeForwardDependencies(tasks, taskId, { maxDepth });
  if (!result || result.length === 0) {
    // possibly truncated by depth limit — rerun with larger maxDepth if needed
  }
} catch (e) { /* handle */ }

Prevention

When it happens

Trigger: Calling the forward-dependency analysis (via analyzeTaskDependencies-style flows) on tasks whose 'dependsOn' chains are deeper than maxDepth.

Common situations: 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.

Related errors


AI-assisted analysis of eyaltoledano/claude-task-master@c0c98d367c (2026-08-29). Data as JSON: /api/errors/e0d9b61c45e14ac7. Report an issue: GitHub.