fixed issue 618 642#761
Merged
Merged
Conversation
|
@devmasalati Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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.
closes #618
closes #642
Summary:
I have implemented a centralized timeout and retry policy framework for all external dependencies in the backend. This ensures that transient failures in services like Gmail, Outlook, Stellar, and various payment gateways do not cause cascading failures or hang the application.
Key Changes
Centralized Service Policies
Created external-services.ts which defines specific timeoutMs and retryPolicy (max attempts, backoff, jitter) for each provider.
Providers covered: gmail, outlook, stellar_rpc, stripe, paystack, exchange_rates, llm, slack, telegram, and outbound_webhooks.
Unified External Service Client
Implemented external-service-client.ts as the standard way to make external requests.
Features built-in AbortController for timeouts and exponential backoff via a centralized retry utility.
Automatically tracks in-memory metrics (total requests, successes, failures, timeouts, retries).
Service Migrations
Migrated core services to use the new client:
Email/OAuth: gmail-token-service.ts, gmail-service.ts, outlook-service.ts.
Payments: paystack.ts.
Rates: frankfurter-provider.ts, fiat-provider.ts, crypto-provider.ts.
Notifications: slack-service.ts, telegram-bot-service.ts.
Others: llm-parser.ts, webhook-service.ts.
Updated blockchain-service.ts and email-service.ts to align with the new policy constants.
Metrics & Monitoring
Updated monitoring-service.ts to aggregate external service metrics.
Exposed a new admin endpoint in index.ts: GET /api/v1/admin/metrics/external-services.
Documentation & Testing
Added EXTERNAL_SERVICE_POLICIES.md detailing the policy for each service.
Added unit tests in external-service-client.test.ts to verify timeout enforcement and retry behavior.
All automated tests passed, confirming that the new client correctly handles service timeouts and retries according to the defined policies.