From 8be4ef47cd51f9c230c5121b5a9f230ca8860a4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hartmut=20N=C3=B6renberg?= Date: Thu, 26 Mar 2026 12:00:57 +0100 Subject: [PATCH] fix: eliminate Sentry import side effects crashing dev server The static import of @sentry/nextjs at module level triggered worker thread creation even when withSentryConfig was only called in production. This caused recurring "Cannot find module vendor-chunks/lib/worker.js" crashes that killed the dev server mid-request. Fix: replaced static import with dynamic require() inside a NODE_ENV === "production" block. In dev mode, the Sentry module is never loaded at all. Co-Authored-By: claude-flow --- apps/web/next.config.ts | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/apps/web/next.config.ts b/apps/web/next.config.ts index 97a2d5c..be5b7c4 100644 --- a/apps/web/next.config.ts +++ b/apps/web/next.config.ts @@ -1,6 +1,5 @@ import path from "path"; import type { NextConfig } from "next"; -import { withSentryConfig } from "@sentry/nextjs"; const nextConfig: NextConfig = { output: "standalone", @@ -48,10 +47,18 @@ const nextConfig: NextConfig = { // 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, { +// Sentry only in production — dynamic import avoids side effects in dev +let exportedConfig: NextConfig = nextConfig; +if (process.env.NODE_ENV === "production") { + try { + const { withSentryConfig } = require("@sentry/nextjs"); + exportedConfig = withSentryConfig(nextConfig, { silent: true, sourcemaps: { disable: true }, telemetry: false, - }) - : nextConfig; + }); + } catch { + // Sentry not available — use raw config + } +} +export default exportedConfig;