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
+ // Because we're going to finish and send the transaction before passing the error onto nextjs, it won't yet
154
+ // have had a chance to set the status to 500, so unless we do it ourselves now, we'll incorrectly report that
155
+ // the transaction was error-free
156
+ res . statusCode = 500 ;
157
+ res . statusMessage = 'Internal Server Error' ;
158
+
153
159
// Make sure we have a chance to finish the transaction and flush events to Sentry before the handler errors
154
160
// out. (Apps which are deployed on Vercel run their API routes in lambdas, and those lambdas will shut down the
155
161
// 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