Skip to content

armgit / ruflo

Public Imported from GitHub
0

🌊 The original agent harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, federation, vector RAG integration, and native Claude Code / Codex / Hermes and many more Integrated

fix(cli): normalize non-Error retry rejections

Rudy Celeklib335bc65e390
diff --git a/v3/@claude-flow/cli/__tests__/production-retry-non-error.test.ts b/v3/@claude-flow/cli/__tests__/production-retry-non-error.test.ts
new file mode 100644
index 0000000000..292dff6b2c
--- /dev/null
+++ b/v3/@claude-flow/cli/__tests__/production-retry-non-error.test.ts
@@ -0,0 +1,31 @@
+import { describe, it, expect } from 'vitest';
+import { withRetry } from '../src/production/retry.js';
+describe('production retry rejection values', () => {
+ it.each(['network reset', null, 42])(
+ 'returns failed retry evidence for %s',
+ async (value) => {
+ const result = await withRetry(
+ async () => {
+ throw value;
+ },
+ { maxAttempts: 2, initialDelayMs: 0, jitter: 0 },
+ );
+ expect(result.success).toBe(false);
+ expect(result.attempts).toBe(2);
+ expect(result.error).toBeInstanceOf(Error);
+ expect(result.error!.message).toBe(String(value));
+ expect(result.retryHistory[0].error).toBe(String(value));
+ },
+ );
+ it('retains Error identity and nonretryable classification', async () => {
+ const error = new Error('authentication denied');
+ const result = await withRetry(
+ async () => {
+ throw error;
+ },
+ { maxAttempts: 2, initialDelayMs: 0 },
+ );
+ expect(result.attempts).toBe(1);
+ expect(result.error).toBe(error);
+ });
+});
diff --git a/v3/@claude-flow/cli/src/production/retry.ts b/v3/@claude-flow/cli/src/production/retry.ts
index d0ca342a75..ef9134e9fd 100644
--- a/v3/@claude-flow/cli/src/production/retry.ts
+++ b/v3/@claude-flow/cli/src/production/retry.ts
@@ -181,7 +181,7 @@ export async function withRetry<T>(
retryHistory,
};
} catch (error) {
- lastError = error as Error;
+ lastError = error instanceof Error ? error : new Error(String(error));
// Check if we should retry
if (!shouldRetryError(lastError, attempt, finalConfig)) {