Skip to content

A modern and easy to use dashboard. 80+ integrations. 20K+ icons built in. Authentication out of the box. No YAML, drag and drop configuration.

feat: ship source maps for readable production stack traces (#6031)

Matt Van Horn89380f81ddd1
diff --git a/Dockerfile b/Dockerfile
index fd852fd9e..86f4918b7 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -20,6 +20,17 @@ ARG DISABLE_REDIS_LOGS='true'
RUN corepack enable pnpm && pnpm build
+# The standalone output tracing omits server chunk source maps (.next/server/**/*.map), which is
+# where production Node stack frames point. Copy the .map files into the standalone tree (preserving
+# directory structure) so the existing standalone COPY ships them, keeping traces readable.
+# See https://github.com/homarr-labs/homarr/issues/5891
+RUN cd apps/nextjs/.next/server && \
+ find . -name '*.map' | while IFS= read -r map; do \
+ dest="../standalone/apps/nextjs/.next/server/$map"; \
+ mkdir -p "$(dirname "$dest")"; \
+ cp "$map" "$dest"; \
+ done
+
FROM base AS runner
WORKDIR /app
@@ -64,6 +75,9 @@ ENV DB_DRIVER='better-sqlite3'
ENV AUTH_PROVIDERS='credentials'
ENV REDIS_IS_EXTERNAL='false'
ENV NODE_ENV='production'
+# Tell Node to symbolicate stack traces using the shipped .map files so production logs
+# show original source locations instead of minified frames, see https://github.com/homarr-labs/homarr/issues/5891
+ENV NODE_OPTIONS='--enable-source-maps'
ENTRYPOINT [ "/app/entrypoint.sh" ]
CMD ["sh", "run.sh"]
diff --git a/apps/nextjs/next.config.ts b/apps/nextjs/next.config.ts
index 636df3f52..a00df48d8 100644
--- a/apps/nextjs/next.config.ts
+++ b/apps/nextjs/next.config.ts
@@ -31,6 +31,8 @@ const nextConfig: NextConfig = {
},
output: "standalone",
reactStrictMode: true,
+ // Ship browser source maps so production client stack traces are readable, see https://github.com/homarr-labs/homarr/issues/5891
+ productionBrowserSourceMaps: true,
// react compiler breaks mantine-react-table, so disabled for now
//reactCompiler: true,
/** We already do typechecking as separate tasks in CI */
@@ -41,6 +43,8 @@ const nextConfig: NextConfig = {
*/
serverExternalPackages: ["dockerode", "isomorphic-dompurify", "jsdom", "better-sqlite3"],
experimental: {
+ // Ship server source maps so production Node stack traces in logs reference original source, see https://github.com/homarr-labs/homarr/issues/5891
+ serverSourceMaps: true,
optimizePackageImports: ["@mantine/core", "@mantine/hooks", "@tabler/icons-react"],
turbopackFileSystemCacheForDev: true,
preloadEntriesOnStart: false,