From 50767a5513c84e849f92ae0629cdcb900b8247e2 Mon Sep 17 00:00:00 2001 From: Jack <57678801+mothershipper@users.noreply.github.com> Date: Thu, 30 May 2024 14:37:15 -0700 Subject: [PATCH] Fix node crash on uncaught exception When fire-and-forget is set, the request promise isn't returned to the log handler, meaning the [catch here](https://github.com/readmeio/metrics-sdks/blob/main/packages/node/src/lib/log.ts#L28-L31) doesn't prevent node from exiting on a request failure. --- packages/node/src/lib/metrics-log.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/node/src/lib/metrics-log.ts b/packages/node/src/lib/metrics-log.ts index fda1fc70d5..6549ca82c1 100644 --- a/packages/node/src/lib/metrics-log.ts +++ b/packages/node/src/lib/metrics-log.ts @@ -132,7 +132,9 @@ export function metricsAPICall( }; if (fireAndForget) { - makeRequest(); + makeRequest().catch((err) => { + // silently catch error so we don't crash the node process! + }); return Promise.resolve({ ids: getLogIds(body), });