From 1ac5bd31cf8b5daffe1680b73fc04a04ae1e44d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Le=C5=9Bniak?= Date: Wed, 17 Jun 2026 15:19:04 +0200 Subject: [PATCH] HRINT-4887 Fix EMFILE empty-asset builds: graceful-fs preload + deploy empty-file gate --- package.json | 4 ++-- scripts/deploy.ps1 | 8 ++++---- scripts/patch-fs.cjs | 5 +++++ 3 files changed, 11 insertions(+), 6 deletions(-) create mode 100644 scripts/patch-fs.cjs diff --git a/package.json b/package.json index 13ae6f080f..ded6ef972d 100644 --- a/package.json +++ b/package.json @@ -6,8 +6,8 @@ "docusaurus": "docusaurus", "start": "npm run generate-icon-types && docusaurus start --no-minify", "start:current": "npm run generate-icon-types && cross-env DOCUSAURUS_VERSIONS='current' docusaurus start --no-minify", - "build": "npm run generate-icon-types && docusaurus build && tsx scripts/split-sitemap.ts && node scripts/generate-robots.js", - "build:current": "npm run generate-icon-types && cross-env DOCUSAURUS_VERSIONS='current' docusaurus build && tsx scripts/split-sitemap.ts && node scripts/generate-robots.js", + "build": "npm run generate-icon-types && node --max-old-space-size=8192 --require ./scripts/patch-fs.cjs ./node_modules/@docusaurus/core/bin/docusaurus.mjs build && tsx scripts/split-sitemap.ts && node scripts/generate-robots.js", + "build:current": "npm run generate-icon-types && cross-env DOCUSAURUS_VERSIONS='current' node --max-old-space-size=8192 --require ./scripts/patch-fs.cjs ./node_modules/@docusaurus/core/bin/docusaurus.mjs build && tsx scripts/split-sitemap.ts && node scripts/generate-robots.js", "swizzle": "docusaurus swizzle", "deploy": "docusaurus deploy", "clear": "docusaurus clear", diff --git a/scripts/deploy.ps1 b/scripts/deploy.ps1 index 04e5f949ea..6109b72941 100644 --- a/scripts/deploy.ps1 +++ b/scripts/deploy.ps1 @@ -185,10 +185,10 @@ if ($LASTEXITCODE) { throw 'Docusaurus build failed' } $BuildDir = [IO.Path]::Combine($PSScriptRoot, '..', 'build') if (-not (Test-Path $BuildDir)) { throw "Build folder not produced ($BuildDir)" } -# Warn (don't block) if the build emitted any empty (0-byte) asset. -$empty = Get-ChildItem $BuildDir -Recurse -File | Where-Object { $_.Length -eq 0 -and $_.Name -ne '.nojekyll' } +# Warn on empty (0-byte) assets under build/assets/ (static/ files may be 0 bytes on purpose). +$empty = Get-ChildItem (Join-Path $BuildDir 'assets') -Recurse -File -ErrorAction SilentlyContinue | Where-Object { $_.Length -eq 0 } if ($empty) { - Write-Warning "Build produced $($empty.Count) empty file(s): $(($empty | Select-Object -First 20 -ExpandProperty Name) -join ', ')" + Write-Warning "Build produced $($empty.Count) empty (0-byte) asset(s) under assets/, e.g.: $(($empty | Select-Object -First 10 -ExpandProperty Name) -join ', ')" } if ($DryRun) { @@ -199,7 +199,7 @@ if ($DryRun) { # Phase 1 — upload new hashed assets without --delete so old bundles remain # on S3 while CloudFront still serves the old index.html from edge cache - # cached aggresively + # cached aggresively Write-Host " [1/4] Upload: hashed assets (assets/*)" -ForegroundColor Gray aws s3 sync $BuildDir "s3://$S3BucketName/" --only-show-errors ` --exclude "*" ` diff --git a/scripts/patch-fs.cjs b/scripts/patch-fs.cjs new file mode 100644 index 0000000000..4f344e9110 --- /dev/null +++ b/scripts/patch-fs.cjs @@ -0,0 +1,5 @@ +try { + require("graceful-fs").gracefulify(require("fs")); +} catch (err) { + console.warn(`[patch-fs] graceful-fs unavailable; EMFILE mitigation skipped: ${err.message}`); +}