-
Notifications
You must be signed in to change notification settings - Fork 49
Closed
Description
Context
The ShapeShift affiliate revenue API aggregates fee data from multiple external swap provider APIs (0x, Bebop, THORChain, Chainflip, Portals, MAYAChain). The endpoint fetches from all providers in parallel and returns combined results.
Current Problem: If any single provider API fails (e.g., Bebop is down), the entire request fails and returns no data. This is because the code uses Promise.all() which rejects if any promise rejects.
Current Implementation
Location: node/proxy/api/src/affiliateRevenue/index.ts
// Current code - if one fails, all fail
const [zrxFees, bebopFees, ...] = await Promise.all([
zrx.getFees(startTimestamp, endTimestamp),
bebop.getFees(startTimestamp, endTimestamp),
// ... other providers
])Solution
Use Promise.allSettled() to handle partial failures gracefully. Return successful data even if some providers fail, and log/report which providers had errors.
Acceptance Criteria
- Replace
Promise.all()withPromise.allSettled() - Aggregate fees from successful providers
- Log failed providers with error details (console.error or structured logging)
- Response returns partial data when some providers fail
- No breaking changes to response schema for the success case
Files to Modify
node/proxy/api/src/affiliateRevenue/index.ts
Implementation Guidance
const results = await Promise.allSettled([
zrx.getFees(start, end),
bebop.getFees(start, end),
// ...
])
const fees: Fees[] = []
results.forEach((result, index) => {
if (result.status === 'fulfilled') {
fees.push(...result.value)
} else {
console.error(`[AffiliateRevenue] ${serviceNames[index]} failed:`, result.reason)
}
})coderabbitai
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Status
Done