From ea6c43f5af819b9488b380627ed8232606db6007 Mon Sep 17 00:00:00 2001 From: ogrechko Date: Thu, 3 Sep 2026 05:18:49 +0000 Subject: [PATCH] Fix production build: npm registry flakiness, stray package-lock.json dir, TS error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - registry.npmjs.org was intermittently ETIMEDOUT mid-download from this host; switched to registry.npmmirror.com (also raised npm's own retry budget as a second line of defense). - frontend/package-lock.json on disk was actually an empty directory (untracked, root-owned — a stray artifact, likely from an old bad bind-mount), which broke `COPY . .` once npm install got past it. - documents/page.tsx had a real type error (selectedItem.file narrowing didn't survive into the .map() closure) that `next dev` never surfaced but `next build`'s stricter check does — fixed by hoisting the narrowed array into selectedFiles once instead of re-narrowing selectedItem.file at each use. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01Gh2UXUQUVBWroWEnn1FLFG --- frontend/Dockerfile | 9 ++++++++- frontend/app/documents/page.tsx | 11 ++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/frontend/Dockerfile b/frontend/Dockerfile index 2992510..b7f4e51 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -9,7 +9,14 @@ WORKDIR /app ENV NODE_OPTIONS=--dns-result-order=ipv4first COPY package.json package-lock.json* ./ -RUN npm install +# registry.npmjs.org itself is unreliable from this host (mid-download +# stalls even with aggressive npm retries) — route through npmmirror.com +# instead, which is consistently reachable from this network. +RUN npm config set registry https://registry.npmmirror.com && \ + npm config set fetch-retries 8 && \ + npm config set fetch-retry-mintimeout 20000 && \ + npm config set fetch-retry-maxtimeout 120000 && \ + npm install COPY . . RUN npm run build diff --git a/frontend/app/documents/page.tsx b/frontend/app/documents/page.tsx index 43de137..88827ec 100644 --- a/frontend/app/documents/page.tsx +++ b/frontend/app/documents/page.tsx @@ -47,6 +47,7 @@ export default async function DocumentsPage({ // Логика определения конкретного файла для отображения let fileForLink: string | null = null; let previewUrl: string | null = null; + const selectedFiles: string[] | null = Array.isArray(selectedItem?.file) ? selectedItem.file : null; if (selectedItem?.file) { if (Array.isArray(selectedItem.file)) { @@ -125,16 +126,16 @@ export default async function DocumentsPage({

{selectedItem?.title ?? "Документ не выбран"}

{/* Вывод списка кнопок, если файлов несколько */} - {selectedItem?.file && Array.isArray(selectedItem.file) && selectedItem.file.length > 1 && ( + {selectedFiles && selectedFiles.length > 1 && (
- {selectedItem.file.map((fileName, idx) => { - const validCurrentIndex = selectedIndex < selectedItem.file.length ? selectedIndex : 0; + {selectedFiles.map((fileName, idx) => { + const validCurrentIndex = selectedIndex < selectedFiles.length ? selectedIndex : 0; const isActive = validCurrentIndex === idx; - + return (