File tree Expand file tree Collapse file tree 1 file changed +6
-0
lines changed
packages/nextjs/src/utils Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Original file line number Diff line number Diff line change @@ -100,6 +100,12 @@ export const withSentry = (origHandler: NextApiHandler): WrappedNextApiHandler =
100
100
captureException ( objectifiedErr ) ;
101
101
}
102
102
103
+ // Make sure we have a chance to finish the transaction and flush events to Sentry before the handler errors
104
+ // out. (Apps which are deployed on Vercel run their API routes in lambdas, and those lambdas will shut down the
105
+ // moment they detect an error, so it's important to get this done before rethrowing the error. Apps not
106
+ // deployed serverlessly will run into this cleanup function again in `res.end(), but it'll just no-op.)
107
+ await finishSentryProcessing ( res ) ;
108
+
103
109
// We rethrow here so that nextjs can do with the error whatever it would normally do. (Sometimes "whatever it
104
110
// would normally do" is to allow the error to bubble up to the global handlers - another reason we need to mark
105
111
// the error as already having been captured.)
You can’t perform that action at this time.
0 commit comments