Skip to content

Commit 2c073d3

Browse files
authored
Fix bug where SDK returned annonymous function instead of return value specified in user code to the Functions Framework. (#1324)
Fix bug where SDK returned annonymous function instead of return value specified in user code to the Functions Framework.
1 parent 632d6b5 commit 2c073d3

File tree

6 files changed

+9
-8
lines changed

6 files changed

+9
-8
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Fix bug where some FireAlerts v2 functions didn't correctly return values back to Functions Framework. (#1324)

src/v2/providers/alerts/alerts.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ export function onAlertPublished<T extends { ["@type"]: string } = any>(
215215
const [opts, alertType, appId] = getOptsAndAlertTypeAndApp(alertTypeOrOpts);
216216

217217
const func = (raw: CloudEvent<unknown>) => {
218-
return wrapTraceContext(handler(convertAlertAndApp(raw) as AlertEvent<T>));
218+
return wrapTraceContext(handler)(convertAlertAndApp(raw) as AlertEvent<T>);
219219
};
220220

221221
func.run = handler;

src/v2/providers/alerts/appDistribution.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,8 @@ export function onNewTesterIosDevicePublished(
250250
const [opts, appId] = getOptsAndApp(appIdOrOptsOrHandler);
251251

252252
const func = (raw: CloudEvent<unknown>) => {
253-
return wrapTraceContext(
254-
handler(convertAlertAndApp(raw) as AppDistributionEvent<NewTesterDevicePayload>)
253+
return wrapTraceContext(handler)(
254+
convertAlertAndApp(raw) as AppDistributionEvent<NewTesterDevicePayload>
255255
);
256256
};
257257

@@ -315,8 +315,8 @@ export function onInAppFeedbackPublished(
315315
const [opts, appId] = getOptsAndApp(appIdOrOptsOrHandler);
316316

317317
const func = (raw: CloudEvent<unknown>) => {
318-
return wrapTraceContext(
319-
handler(convertAlertAndApp(raw) as AppDistributionEvent<InAppFeedbackPayload>)
318+
return wrapTraceContext(handler)(
319+
convertAlertAndApp(raw) as AppDistributionEvent<InAppFeedbackPayload>
320320
);
321321
};
322322

src/v2/providers/alerts/billing.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ export function onOperation<T>(
152152
}
153153

154154
const func = (raw: CloudEvent<unknown>) => {
155-
return wrapTraceContext(handler(convertAlertAndApp(raw) as BillingEvent<T>));
155+
return wrapTraceContext(handler)(convertAlertAndApp(raw) as BillingEvent<T>);
156156
};
157157

158158
func.run = handler;

src/v2/providers/testLab.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ export function onTestMatrixCompleted(
190190
const specificOpts = optionsToEndpoint(optsOrHandler);
191191

192192
const func: any = (raw: CloudEvent<unknown>) => {
193-
return wrapTraceContext(handler(raw as CloudEvent<TestMatrixCompletedData>));
193+
return wrapTraceContext(handler)(raw as CloudEvent<TestMatrixCompletedData>);
194194
};
195195
func.run = handler;
196196

src/v2/trace.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@ export function wrapTraceContext(
2828
// eslint-disable-next-line prefer-spread
2929
return handler.apply(null, args);
3030
}
31-
traceContext.run(traceParent, handler, ...args);
31+
return traceContext.run(traceParent, handler, ...args);
3232
};
3333
}

0 commit comments

Comments
 (0)