diff --git a/apps/web/next.config.ts b/apps/web/next.config.ts index 8ee077a..c087caf 100644 --- a/apps/web/next.config.ts +++ b/apps/web/next.config.ts @@ -45,10 +45,12 @@ const nextConfig: NextConfig = { }, }; -export default withSentryConfig(nextConfig, { - silent: true, - sourcemaps: { - disable: true, - }, - telemetry: false, -}); +// Only wrap with Sentry in production — the worker.js crash in dev mode +// (vendor-chunks/lib/worker.js MODULE_NOT_FOUND) makes the dev server unstable +export default process.env.NODE_ENV === "production" + ? withSentryConfig(nextConfig, { + silent: true, + sourcemaps: { disable: true }, + telemetry: false, + }) + : nextConfig; diff --git a/apps/web/src/instrumentation.ts b/apps/web/src/instrumentation.ts index 4df5ea8..3ee6217 100644 --- a/apps/web/src/instrumentation.ts +++ b/apps/web/src/instrumentation.ts @@ -1,12 +1,19 @@ -import * as Sentry from "@sentry/nextjs"; - export async function register() { - if (process.env.NEXT_RUNTIME === "nodejs") { - await import("../sentry.server.config"); - } - if (process.env.NEXT_RUNTIME === "edge") { - await import("../sentry.edge.config"); + // Only load Sentry in production — the worker.js crash in dev mode + // (vendor-chunks/lib/worker.js MODULE_NOT_FOUND) makes the dev server unstable + if (process.env.NODE_ENV === "production") { + if (process.env.NEXT_RUNTIME === "nodejs") { + await import("../sentry.server.config"); + } + if (process.env.NEXT_RUNTIME === "edge") { + await import("../sentry.edge.config"); + } } } -export const onRequestError = Sentry.captureRequestError; +export async function onRequestError(...args: unknown[]) { + if (process.env.NODE_ENV === "production") { + const Sentry = await import("@sentry/nextjs"); + (Sentry.captureRequestError as Function)(...args); + } +}