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