Skip to content

Commit f7a4846

Browse files
committed
mark wrapped handlers as wrapped
1 parent 237cf9f commit f7a4846

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

packages/nextjs/src/utils/withSentry.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,10 @@ export const withSentry = (origHandler: NextApiHandler): WrappedNextApiHandler =
179179
// a promise here rather than a real result, and it saves us the overhead of an `await` call.)
180180
return boundHandler();
181181
};
182+
183+
// Flag the original handler as already having been wrapped, to prevent it from being wrapped twice (which it could
184+
// be, if someone has already wrapped it manually and then we come along and auto-wrap it)
185+
wrappedHandler.__sentry_wrapped__ = true;
182186
};
183187

184188
type ResponseEndMethod = AugmentedNextApiResponse['end'];

0 commit comments

Comments
 (0)