perf: dynamically import sentry lib in catch clause (#19607)

This commit is contained in:
Benny Joo authored and GitHub committed 2025-02-27 18:17:45 +00:00
1 parent 0ad5770bb9
commit 2cf76737d8
1 file changed
+1 -1
+1 -1
View File
@@ -1,4 +1,3 @@
import { captureException } from "@sentry/nextjs";
import type { Params } from "app/_types";
import { ApiError } from "next/dist/server/api-utils";
import type { NextRequest } from "next/server";
@@ -19,6 +18,7 @@ export const apiRouteMiddleware =
// we don't want to report Bad Request errors to Sentry / console
if (!(serverError.statusCode >= 400 && serverError.statusCode < 500)) {
console.error(error);
const captureException = (await import("@sentry/nextjs")).captureException;
captureException(error);
}
return NextResponse.json(