fix(hooks): add network errors to noRetryPatterns, update E2E test

- Add ENOTFOUND, ENETUNREACH, EAI_AGAIN to noRetryPatterns to prevent
  infinite retries on network errors
- Update E2E test to expect exit code 2 (block) when CLIProxy unavailable
- Fix debug message expectation in test
This commit is contained in:
kaitranntt
2026-02-04 00:59:10 -05:00
parent 51b719ef34
commit 1201b4bb4b
2 changed files with 15 additions and 7 deletions
+6 -2
View File
@@ -215,9 +215,13 @@ async function analyzeWithRetry(base64Data, mediaType, timeoutMs) {
lastError = err;
const isLastModel = i === models.length - 1;
// Don't retry on certain errors (auth, rate limit, timeout, file access)
// Don't retry on certain errors (auth, rate limit, timeout, file access, network)
const errMsg = err.message || '';
const noRetryPatterns = ['AUTH_ERROR', 'RATE_LIMIT', 'TIMEOUT', 'EACCES', 'EPERM', 'ECONNREFUSED'];
const noRetryPatterns = [
'AUTH_ERROR', 'RATE_LIMIT', 'TIMEOUT',
'EACCES', 'EPERM', 'ECONNREFUSED',
'ENOTFOUND', 'ENETUNREACH', 'EAI_AGAIN' // Network errors - no point retrying
];
const shouldNotRetry = noRetryPatterns.some(p => errMsg.includes(p));
if (shouldNotRetry || isLastModel) {