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 & {
48
48
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
49
49
export const withSentry = ( origHandler : NextApiHandler ) : WrappedNextApiHandler => {
50
50
// 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
+ ) {
52
56
// first order of business: monkeypatch `res.end()` so that it will wait for us to send events to sentry before it
53
57
// fires (if we don't do this, the lambda will close too early and events will be either delayed or lost)
54
58
// eslint-disable-next-line @typescript-eslint/unbound-method
@@ -183,6 +187,8 @@ export const withSentry = (origHandler: NextApiHandler): WrappedNextApiHandler =
183
187
// Flag the original handler as already having been wrapped, to prevent it from being wrapped twice (which it could
184
188
// be, if someone has already wrapped it manually and then we come along and auto-wrap it)
185
189
wrappedHandler . __sentry_wrapped__ = true ;
190
+
191
+ return wrappedHandler ;
186
192
} ;
187
193
188
194
type ResponseEndMethod = AugmentedNextApiResponse [ 'end' ] ;
You can’t perform that action at this time.
0 commit comments