ruvnet/ruflo · error · Error

JSON.stringify(response.error)

Error message

JSON.stringify(response.error)

What it means

task_cancel mirrors task_status: it attempts cancellation through the swarm orchestrator and, on any orchestrator failure, falls back to the local taskStore Map. If the task ID is absent from that Map, the simple implementation throws 'Task not found: <id>' before any cancellation logic runs. Note the orchestrator branch may have already logged its own failure — the not-found error can therefore mask an orchestrator connectivity problem rather than a genuinely missing task.

Source

Thrown at ruflo/src/ruvocal/src/lib/APIClient.ts:138

		models: {
			...endpoint(fetcher, `${baseUrl}/models`),
			old: endpoint(fetcher, `${baseUrl}/models/old`),
			refresh: endpoint(fetcher, `${baseUrl}/models/refresh`),
		},
		"public-config": endpoint(fetcher, `${baseUrl}/public-config`),
		"feature-flags": endpoint(fetcher, `${baseUrl}/feature-flags`),
		debug: {
			config: endpoint(fetcher, `${baseUrl}/debug/config`),
			refresh: endpoint(fetcher, `${baseUrl}/debug/refresh`),
		},
		export: endpoint(fetcher, `${baseUrl}/export`),
	};
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function handleResponse(response: ApiResponse<any>): any {
	if (response.error) {
		throw new Error(JSON.stringify(response.error));
	}

	if (response.data === null) {
		return null;
	}

	return superjson.parse(
		typeof response.data === "string" ? response.data : JSON.stringify(response.data)
	);
}

View on GitHub (pinned to fa13ee4ad6)

Solutions

  1. Verify the task exists first via task_status or task list; treat 'not found' after a restart as already-gone rather than an error condition
  2. Look for 'Failed to cancel task via orchestrator:' in server logs — if present, fix the orchestrator connection instead of chasing the task ID
  3. Re-create and then cancel if you genuinely need a cancel record for audit purposes
  4. Wrap cancel in a tolerant handler that treats this specific message as a no-op success

Example fix

// before
await client.callTool('task_cancel', { taskId }); // throws [1134] after server restart

// after
try {
  await client.callTool('task_cancel', { taskId, reason: 'superseded' });
} catch (e) {
  if (!(e instanceof Error) || !e.message.includes('Task not found')) throw e;
  // task store was reset by a restart; nothing to cancel
}
Defensive patterns

Strategy: fallback

Validate before calling

try {
  await client.callTool('task_status', { taskId });
} catch {
  // task unknown — treat cancel as already-satisfied
}
// only call task_cancel when the status call succeeded

Try / catch

try {
  const r = await client.callTool('task_cancel', { taskId, reason });
} catch (e) {
  if (e instanceof Error && e.message.startsWith('Task not found')) {
    return { taskId, cancelled: true, note: 'task already gone (restart or pruned)' };
  }
  throw e;
}

Prevention

When it happens

Trigger: Cancelling a task created before the last server restart; the orchestrator threw (console shows 'Failed to cancel task via orchestrator:') and the local store has no such task; cancelling an ID from another swarm's namespace; already-completed tasks are fine (they return cancelled:false), but unknown IDs throw.

Common situations: Cleanup scripts that try to cancel 'all tasks' after a restart without checking what still exists; race where the task finished and was pruned before the cancel arrived; misconfigured orchestrator making every call fall through to the empty local store.

Related errors


AI-assisted analysis of ruvnet/ruflo@fa13ee4ad6 (2026-08-18). Data as JSON: /api/errors/cd4c888633265097. Report an issue: GitHub.