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 @@ -48,7 +48,11 @@ export type AugmentedNextApiResponse = NextApiResponse & {
4848// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
4949export const withSentry = ( origHandler : NextApiHandler ) : WrappedNextApiHandler => {
5050 // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
51- return async ( req , res ) => {
51+ const wrappedHandler : WrappedNextApiHandler = async function (
52+ this : WrappedNextApiHandler ,
53+ req : NextApiRequest ,
54+ res : NextApiResponse ,
55+ ) {
5256 // first order of business: monkeypatch `res.end()` so that it will wait for us to send events to sentry before it
5357 // fires (if we don't do this, the lambda will close too early and events will be either delayed or lost)
5458 // eslint-disable-next-line @typescript-eslint/unbound-method
@@ -183,6 +187,8 @@ export const withSentry = (origHandler: NextApiHandler): WrappedNextApiHandler =
183187 // Flag the original handler as already having been wrapped, to prevent it from being wrapped twice (which it could
184188 // be, if someone has already wrapped it manually and then we come along and auto-wrap it)
185189 wrappedHandler . __sentry_wrapped__ = true ;
190+
191+ return wrappedHandler ;
186192} ;
187193
188194type ResponseEndMethod = AugmentedNextApiResponse [ 'end' ] ;
You can’t perform that action at this time.
0 commit comments