From 7dff9bcf8b45d18aa87f10f5bed1f855b2d1df63 Mon Sep 17 00:00:00 2001 From: ConjunctiveNormalForm Date: Wed, 28 Aug 2024 12:58:39 -0400 Subject: [PATCH 1/2] log allSettled return value --- lib/quoters/WebhookQuoter.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/quoters/WebhookQuoter.ts b/lib/quoters/WebhookQuoter.ts index 4342238..637df9e 100644 --- a/lib/quoters/WebhookQuoter.ts +++ b/lib/quoters/WebhookQuoter.ts @@ -58,7 +58,9 @@ export class WebhookQuoter implements Quoter { const quotes = await Promise.all(enabledEndpoints.map((e) => this.fetchQuote(e, request))); // should not await and block - Promise.allSettled(disabledEndpoints.map((e) => this.notifyBlock(e))); + Promise.allSettled(disabledEndpoints.map((e) => this.notifyBlock(e))).then((results) => { + this.log.info({ results }, 'Notified disabled endpoints'); + }); return quotes.filter((q) => q !== null) as QuoteResponse[]; } From 019b1556a55e66f4baa1ec21dd6fa2ae496fa533 Mon Sep 17 00:00:00 2001 From: ConjunctiveNormalForm Date: Wed, 28 Aug 2024 13:09:42 -0400 Subject: [PATCH 2/2] axios.post.catch --- lib/quoters/WebhookQuoter.ts | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/lib/quoters/WebhookQuoter.ts b/lib/quoters/WebhookQuoter.ts index 637df9e..311d06e 100644 --- a/lib/quoters/WebhookQuoter.ts +++ b/lib/quoters/WebhookQuoter.ts @@ -314,20 +314,17 @@ export class WebhookQuoter implements Quoter { timeout: NOTIFICATION_TIMEOUT_MS, ...(!!status.webhook.headers && { headers: status.webhook.headers }), }; - try { - axios.post( + axios + .post( status.webhook.endpoint, { blockUntilTimestamp: status.blockUntil, }, axiosConfig - ); - } catch (e) { - this.log.error( - { endpoint: status.webhook.endpoint, error: e }, - `Error notifying block to ${status.webhook.endpoint}` - ); - } + ) + .catch((e) => { + this.log.error({ endpoint: status.webhook.endpoint, error: e }, `Axios error notifying block`); + }); } }