diff --git a/.github/workflows/code-quality.yml b/.github/workflows/code-quality.yml index 8a01559a9..98a247460 100644 --- a/.github/workflows/code-quality.yml +++ b/.github/workflows/code-quality.yml @@ -163,3 +163,65 @@ jobs: run: cp .env.example .env - name: Build run: pnpm turbo build --affected + + memory-regression: + runs-on: ubuntu-latest + timeout-minutes: 15 + steps: + - uses: actions/checkout@v6 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v4 + - name: Build Docker image + uses: docker/build-push-action@v7 + with: + platforms: linux/amd64 + context: . + push: false + load: true + tags: homarr-memory-test + network: host + cache-from: type=gha + cache-to: type=gha,mode=max + env: + SKIP_ENV_VALIDATION: true + - name: Start container and measure memory + run: | + docker run -d --name homarr-mem-test -p 17575:7575 homarr-memory-test + # Wait for container to be healthy (up to 60s) + healthy=false + for i in $(seq 1 30); do + if curl -sf http://localhost:17575/api/health 2>/dev/null; then + echo "Container healthy after $((i * 2))s" + healthy=true + break + fi + sleep 2 + done + if [ "$healthy" != "true" ]; then + echo "ERROR: Container never became healthy" + docker logs homarr-mem-test --tail 50 + exit 1 + fi + # Warm up: hit the dashboard page a few times + for i in $(seq 1 5); do + curl -sf http://localhost:17575/ > /dev/null 2>&1 || true + sleep 2 + done + # Measure RSS after warmup + MEM_KB=$(docker stats --no-stream --format '{{.MemUsage}}' homarr-mem-test | sed 's| /.*||') + echo "Raw memory: $MEM_KB" + # Convert to numeric MB (handles GiB and MiB suffixes) + MEM_NUM=$(echo "$MEM_KB" | awk '{ + if ($0 ~ /GiB/) { gsub(/GiB/,""); print $1 * 1024 } + else if ($0 ~ /MiB/) { gsub(/MiB/,""); print $1 } + else if ($0 ~ /KiB/) { gsub(/KiB/,""); print $1 / 1024 } + else { print $1 / 1048576 } + }') + echo "Memory usage: ${MEM_NUM} MB" + MAX_MB=700 + if awk "BEGIN {exit !($MEM_NUM > $MAX_MB)}"; then + echo "ERROR: Memory usage ${MEM_NUM} MB exceeds ${MAX_MB} MB threshold" + docker logs homarr-mem-test --tail 50 + exit 1 + fi + echo "Memory check passed: ${MEM_NUM} MB <= ${MAX_MB} MB" diff --git a/Dockerfile b/Dockerfile index d50756e39..9c4d41de8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,17 +20,6 @@ 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 @@ -75,9 +64,6 @@ 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 a00df48d8..636df3f52 100644 --- a/apps/nextjs/next.config.ts +++ b/apps/nextjs/next.config.ts @@ -31,8 +31,6 @@ 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 */ @@ -43,8 +41,6 @@ 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,