File tree 1 file changed +9
-5
lines changed
packages/serverless/src/gcpfunction
1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -21,15 +21,17 @@ export function wrapEventFunction(
21
21
}
22
22
23
23
/** */
24
- function _wrapEventFunction (
25
- fn : EventFunction | EventFunctionWithCallback ,
24
+ function _wrapEventFunction < F extends EventFunction | EventFunctionWithCallback > (
25
+ fn : F ,
26
26
wrapOptions : Partial < EventFunctionWrapperOptions > = { } ,
27
- ) : EventFunctionWithCallback {
27
+ ) : ( ... args : Parameters < F > ) => ReturnType < F > | Promise < void > {
28
28
const options : EventFunctionWrapperOptions = {
29
29
flushTimeout : 2000 ,
30
30
...wrapOptions ,
31
31
} ;
32
- return ( data , context , callback ) => {
32
+ return ( ...eventFunctionArguments : Parameters < F > ) : ReturnType < F > | Promise < void > => {
33
+ const [ data , context , callback ] = eventFunctionArguments ;
34
+
33
35
const hub = getCurrentHub ( ) ;
34
36
35
37
const transaction = hub . startTransaction ( {
@@ -62,7 +64,9 @@ function _wrapEventFunction(
62
64
__DEBUG_BUILD__ && logger . error ( e ) ;
63
65
} )
64
66
. then ( ( ) => {
65
- callback ( ...args ) ;
67
+ if ( typeof callback === 'function' ) {
68
+ callback ( ...args ) ;
69
+ }
66
70
} ) ;
67
71
} ) ;
68
72
You can’t perform that action at this time.
0 commit comments