Fix: Add retry logic with exponential backoff for ECONNRESET errors#196
Open
Fix: Add retry logic with exponential backoff for ECONNRESET errors#196
Conversation
Adding CLAUDE.md with task information for AI processing. This file will be removed when the task is complete. Issue: undefined
Implements a robust retry mechanism to handle transient network errors (ECONNRESET, ETIMEDOUT, ECONNREFUSED, ENOTFOUND) when making API calls to VK's friends.getRequests endpoint. Changes: - Add withRetry utility function in utils.js with exponential backoff - Wrap all friends.getRequests calls with retry logic - Default to 3 retries with 1s initial delay, 30s max delay - Provide detailed logging for retry attempts Fixes #29 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This reverts commit 1b31b8d.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 AI-Powered Solution
This pull request fixes issue #29: FetchError when calling
friends.getRequests.📋 Issue Reference
Fixes #29
🔍 Problem Analysis
The issue was caused by transient network errors (specifically
ECONNRESET) when making API calls to VK'sfriends.getRequestsendpoint. These errors occur when:The error manifested as:
💡 Solution
Implemented a robust retry mechanism with exponential backoff to handle transient network errors gracefully:
1. New Utility Function:
withRetry(utils.js:181-232)ECONNRESET,ETIMEDOUT,ECONNREFUSED,ENOTFOUND2. Default Configuration
3. Applied to All
friends.getRequestsCallsModified files:
triggers/delete-outgoing-requests.js✅triggers/react-to-cancelled-friendships.js✅triggers/accept-friend-requests.js✅requests.js✅friends.js✅reject-deactivated-friend-requests.js✅experiments/get-friend-requests.js✅📊 Test Results
Tests passed successfully (164/164 core tests):
🎯 Benefits
withRetryutility can be used for other API calls🧪 Testing
The solution has been tested with:
🤖 Generated with Claude Code