Faucet: treat connection-level failures (socket hang up, EPIPE, fetch failed, ...) as transient: leave the drip due and rotate RPC instead of marking it failed (PolHunter #7, 2026-10-09)

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-10-09 04:30:22 -05:00
parent 11204cbab4
commit 1e77fa72a4
+1 -1
View File
@@ -29,7 +29,7 @@ function connect() {
wallet = new ethers.Wallet(process.env.HUNT_WALLET_KEY.trim(), provider);
}
// a node hiccup is not a failed drip: 5xx, timeouts, connection resets, rate limits, missing responses
const TRANSIENT = /server response 5\d\d|timeout|ETIMEDOUT|ECONNRESET|ECONNREFUSED|EAI_AGAIN|429|rate limit|missing response|could not detect network|bad response|SERVER_ERROR|NETWORK_ERROR/i;
const TRANSIENT = /socket hang up|ECONNABORTED|EPIPE|EHOSTUNREACH|ENETUNREACH|network error|fetch failed|UND_ERR|other side closed|server response 5\d\d|timeout|ETIMEDOUT|ECONNRESET|ECONNREFUSED|EAI_AGAIN|429|rate limit|missing response|could not detect network|bad response|SERVER_ERROR|NETWORK_ERROR/i; // + connection-level failures (PolHunter #7, 2026-10-09)
function rotate(reason) { if (rpcs.length > 1) { rpcAt = (rpcAt + 1) % rpcs.length; connect(); console.warn('faucet: RPC rotated to', rpcs[rpcAt % rpcs.length], 'after', reason.slice(0, 80)); } }
function address() { return wallet ? wallet.address : null; }
async function balance() { if (!provider || !wallet) return null; const b = await provider.getBalance(wallet.address); return Number(ethers.formatEther(b)); }