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 & {
51
51
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
52
52
export const withSentry = ( origHandler : NextApiHandler ) : WrappedNextApiHandler => {
53
53
// 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
+ ) {
55
59
// first order of business: monkeypatch `res.end()` so that it will wait for us to send events to sentry before it
56
60
// fires (if we don't do this, the lambda will close too early and events will be either delayed or lost)
57
61
// eslint-disable-next-line @typescript-eslint/unbound-method
@@ -182,6 +186,8 @@ export const withSentry = (origHandler: NextApiHandler): WrappedNextApiHandler =
182
186
// a promise here rather than a real result, and it saves us the overhead of an `await` call.)
183
187
return boundHandler ( ) ;
184
188
} ;
189
+
190
+ return wrappedHandler ;
185
191
} ;
186
192
187
193
type ResponseEndMethod = AugmentedNextApiResponse [ 'end' ] ;
You can’t perform that action at this time.
0 commit comments