File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed
packages/serverless/src/gcpfunction Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -21,15 +21,17 @@ export function wrapEventFunction(
2121}
2222
2323/** */
24- function _wrapEventFunction (
25- fn : EventFunction | EventFunctionWithCallback ,
24+ function _wrapEventFunction < F extends EventFunction | EventFunctionWithCallback > (
25+ fn : F ,
2626 wrapOptions : Partial < EventFunctionWrapperOptions > = { } ,
27- ) : EventFunctionWithCallback {
27+ ) : ( ... args : Parameters < F > ) => ReturnType < F > | Promise < void > {
2828 const options : EventFunctionWrapperOptions = {
2929 flushTimeout : 2000 ,
3030 ...wrapOptions ,
3131 } ;
32- return ( data , context , callback ) => {
32+ return ( ...eventFunctionArguments : Parameters < F > ) : ReturnType < F > | Promise < void > => {
33+ const [ data , context , callback ] = eventFunctionArguments ;
34+
3335 const hub = getCurrentHub ( ) ;
3436
3537 const transaction = hub . startTransaction ( {
@@ -62,7 +64,9 @@ function _wrapEventFunction(
6264 __DEBUG_BUILD__ && logger . error ( e ) ;
6365 } )
6466 . then ( ( ) => {
65- callback ( ...args ) ;
67+ if ( typeof callback === 'function' ) {
68+ callback ( ...args ) ;
69+ }
6670 } ) ;
6771 } ) ;
6872
You can’t perform that action at this time.
0 commit comments