Skip to content

Commit 52689ee

Browse files
authored
fix(node): ensure fireAndForget option is respected (#1004)
| 🚥 Resolves ISSUE_ID | | :------------------- | ## 🧰 Changes [ReadMe Community Slack Thread](https://readmecommunity.slack.com/archives/C066P4UL27N/p1717105349072129)! Fixing an issue noted by the folks at Mothership where our `fireAndForget` option wasn't being respected in the `node` package. This is largely due to the option not being passed in correctly to the function argument. Taking this fix a step further and exposing the entire user-provided `options` object to this function. ## 🧬 QA & Testing Provide as much information as you can on how to test what you've done.
1 parent d97b3d0 commit 52689ee

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

packages/node/src/lib/log.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function doSend(readmeApiKey: string, options: Options) {
2525
queue = [];
2626

2727
// Make the log call
28-
metricsAPICall(readmeApiKey, json).catch(e => {
28+
metricsAPICall(readmeApiKey, json, options).catch(e => {
2929
// Silently discard errors and timeouts.
3030
if (options.development) throw e;
3131
});

packages/node/src/lib/metrics-log.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { Options } from './log';
12
import type { UUID } from 'crypto';
23
import type { Har } from 'har-format';
34
import type { Response } from 'node-fetch';
@@ -88,11 +89,7 @@ function getLogIds(body: OutgoingLogBody | OutgoingLogBody[]): LogId {
8889
return body._id;
8990
}
9091

91-
export function metricsAPICall(
92-
readmeAPIKey: string,
93-
body: OutgoingLogBody[],
94-
fireAndForget = false,
95-
): Promise<LogResponse> {
92+
export function metricsAPICall(readmeAPIKey: string, body: OutgoingLogBody[], options: Options): Promise<LogResponse> {
9693
const signal = timeoutSignal(config.timeout);
9794
const encodedKey = Buffer.from(`${readmeAPIKey}:`).toString('base64');
9895

@@ -131,7 +128,7 @@ export function metricsAPICall(
131128
});
132129
};
133130

134-
if (fireAndForget) {
131+
if (options.fireAndForget) {
135132
makeRequest();
136133
return Promise.resolve<LogResponse>({
137134
ids: getLogIds(body),

0 commit comments

Comments
 (0)