Skip to content

Commit

Permalink
Fix bug where SDK returned annonymous function instead of return valu…
Browse files Browse the repository at this point in the history
…e 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.
  • Loading branch information
taeold authored Dec 7, 2022
1 parent 632d6b5 commit 2c073d3
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Fix bug where some FireAlerts v2 functions didn't correctly return values back to Functions Framework. (#1324)
2 changes: 1 addition & 1 deletion src/v2/providers/alerts/alerts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ export function onAlertPublished<T extends { ["@type"]: string } = any>(
const [opts, alertType, appId] = getOptsAndAlertTypeAndApp(alertTypeOrOpts);

const func = (raw: CloudEvent<unknown>) => {
return wrapTraceContext(handler(convertAlertAndApp(raw) as AlertEvent<T>));
return wrapTraceContext(handler)(convertAlertAndApp(raw) as AlertEvent<T>);
};

func.run = handler;
Expand Down
8 changes: 4 additions & 4 deletions src/v2/providers/alerts/appDistribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,8 @@ export function onNewTesterIosDevicePublished(
const [opts, appId] = getOptsAndApp(appIdOrOptsOrHandler);

const func = (raw: CloudEvent<unknown>) => {
return wrapTraceContext(
handler(convertAlertAndApp(raw) as AppDistributionEvent<NewTesterDevicePayload>)
return wrapTraceContext(handler)(
convertAlertAndApp(raw) as AppDistributionEvent<NewTesterDevicePayload>
);
};

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

const func = (raw: CloudEvent<unknown>) => {
return wrapTraceContext(
handler(convertAlertAndApp(raw) as AppDistributionEvent<InAppFeedbackPayload>)
return wrapTraceContext(handler)(
convertAlertAndApp(raw) as AppDistributionEvent<InAppFeedbackPayload>
);
};

Expand Down
2 changes: 1 addition & 1 deletion src/v2/providers/alerts/billing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export function onOperation<T>(
}

const func = (raw: CloudEvent<unknown>) => {
return wrapTraceContext(handler(convertAlertAndApp(raw) as BillingEvent<T>));
return wrapTraceContext(handler)(convertAlertAndApp(raw) as BillingEvent<T>);
};

func.run = handler;
Expand Down
2 changes: 1 addition & 1 deletion src/v2/providers/testLab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ export function onTestMatrixCompleted(
const specificOpts = optionsToEndpoint(optsOrHandler);

const func: any = (raw: CloudEvent<unknown>) => {
return wrapTraceContext(handler(raw as CloudEvent<TestMatrixCompletedData>));
return wrapTraceContext(handler)(raw as CloudEvent<TestMatrixCompletedData>);
};
func.run = handler;

Expand Down
2 changes: 1 addition & 1 deletion src/v2/trace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ export function wrapTraceContext(
// eslint-disable-next-line prefer-spread
return handler.apply(null, args);
}
traceContext.run(traceParent, handler, ...args);
return traceContext.run(traceParent, handler, ...args);
};
}

0 comments on commit 2c073d3

Please sign in to comment.