File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed
packages/nextjs/src/utils Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -20,7 +20,10 @@ export const withSentry = (handler: NextApiHandler): WrappedNextApiHandler => {
2020 local . add ( req ) ;
2121 local . add ( res ) ;
2222
23- local . run ( async ( ) => {
23+ // `local.bind` causes everything to run inside a domain, just like `local.run` does, but it also lets the callback
24+ // return a value. In our case, all any of the codepaths return is a promise of `void`, but nextjs still counts on
25+ // getting that before it will finish the response.
26+ const boundHandler = local . bind ( async ( ) => {
2427 try {
2528 const currentScope = getCurrentHub ( ) . getScope ( ) ;
2629
@@ -87,5 +90,7 @@ export const withSentry = (handler: NextApiHandler): WrappedNextApiHandler => {
8790 }
8891 }
8992 } ) ;
93+
94+ return await boundHandler ( ) ;
9095 } ;
9196} ;
You can’t perform that action at this time.
0 commit comments