Skip to content

Commit 8d7d864

Browse files
committed
fix(node): prevent 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.
1 parent d97b3d0 commit 8d7d864

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Diff for: packages/node/src/lib/metrics-log.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,9 @@ export function metricsAPICall(
132132
};
133133

134134
if (fireAndForget) {
135-
makeRequest();
135+
makeRequest().catch((err) => {
136+
// silently catch error so we don't crash the node process!
137+
});
136138
return Promise.resolve<LogResponse>({
137139
ids: getLogIds(body),
138140
});

0 commit comments

Comments
 (0)