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
+ // Because we're going to finish and send the transaction before passing the error onto nextjs, it won't yet
104
+ // have had a chance to set the status to 500, so unless we do it ourselves now, we'll incorrectly report that
105
+ // the transaction was error-free
106
+ res . statusCode = 500 ;
107
+ res . statusMessage = 'Internal Server Error' ;
108
+
103
109
// Make sure we have a chance to finish the transaction and flush events to Sentry before the handler errors
104
110
// out. (Apps which are deployed on Vercel run their API routes in lambdas, and those lambdas will shut down the
105
111
// moment they detect an error, so it's important to get this done before rethrowing the error. Apps not
You can’t perform that action at this time.
0 commit comments