bhussainshoots
03/13/2026, 3:41 AMtypescript
// Simple circuit state
let failures = 0;
const THRESHOLD = 5;
const COOLDOWN = 300000; // 5min
if (failures >= THRESHOLD && Date.now() - lastFailure < COOLDOWN) {
return { success: false, fallback: cachedData };
}
Store failures and lastFailure in the Store piece (global storage) so it persists across executions.
This prevents your automation from hanging for 30s+ when the CRM is down, and stops you from DDoSing your vendor's recovery efforts.
What's your go-to pattern for handling external API outages?
https://cdn.discordapp.com/attachments/1060469824104439838/1481859623857422366/1773373244650-post.png?ex=69b4d8d1&is=69b38751&hm=b7d3e2f0d31510d07a1afde070a980970bd1681f1dd00c522544e254661cc6d5&