Skip to content

Commit

Permalink
Fix node crash on uncaught exception
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mothershipper authored May 30, 2024
1 parent d97b3d0 commit 50767a5
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/node/src/lib/metrics-log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<LogResponse>({
ids: getLogIds(body),
});
Expand Down

0 comments on commit 50767a5

Please sign in to comment.