Increased timeout and better error handling on invoice polling

This commit is contained in:
austinkelsay 2024-11-15 21:01:40 -06:00
parent aaeb5de1fe
commit 4e894e637c
No known key found for this signature in database
GPG Key ID: 44CB4EC6D9F2FA02

View File

@ -58,14 +58,18 @@ export default async function handler(req, res) {
continue;
}
// Check payment status
// Add axios timeout configuration
const axiosConfig = {
timeout: 5000, // 5 second timeout
headers: {
'Grpc-Metadata-macaroon': foundAddress.invoiceMacaroon,
}
};
// Check payment status with timeout handling
const response = await axios.get(
`https://${foundAddress.lndHost}:${foundAddress.lndPort}/v1/invoice/${paymentHash}`,
{
headers: {
'Grpc-Metadata-macaroon': foundAddress.invoiceMacaroon,
}
}
axiosConfig
);
if (!response.data) {
@ -124,6 +128,11 @@ export default async function handler(req, res) {
results.processed++;
} catch (error) {
if (error.code === 'ECONNRESET' || error.code === 'ETIMEDOUT') {
console.error(`Connection issue with LND node for ${foundAddress.lndHost}: ${error.message}`);
results.errors++;
continue;
}
console.error('Error processing invoice:', error);
results.errors++;
}