File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed
packages/nextjs/src/utils Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -51,7 +51,11 @@ export type AugmentedNextApiResponse = NextApiResponse & {
5151// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
5252export const withSentry = ( origHandler : NextApiHandler ) : WrappedNextApiHandler => {
5353 // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
54- return async ( req , res ) => {
54+ const wrappedHandler : WrappedNextApiHandler = async function (
55+ this : WrappedNextApiHandler ,
56+ req : NextApiRequest ,
57+ res : NextApiResponse ,
58+ ) {
5559 // first order of business: monkeypatch `res.end()` so that it will wait for us to send events to sentry before it
5660 // fires (if we don't do this, the lambda will close too early and events will be either delayed or lost)
5761 // eslint-disable-next-line @typescript-eslint/unbound-method
@@ -182,6 +186,8 @@ export const withSentry = (origHandler: NextApiHandler): WrappedNextApiHandler =
182186 // a promise here rather than a real result, and it saves us the overhead of an `await` call.)
183187 return boundHandler ( ) ;
184188 } ;
189+
190+ return wrappedHandler ;
185191} ;
186192
187193type ResponseEndMethod = AugmentedNextApiResponse [ 'end' ] ;
You can’t perform that action at this time.
0 commit comments