EMFILE: too many open files during build
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 11.2k
- Forks
- 899
- Avg merge
- 2d 24m
- Merged PRs (30d)
- 40
Description
Environment
nitropack@2.11.12
nodejs v22.14.0
Reproduction
See problem description. I think the problem itself is clear enough.
Describe the bug
https://github.com/nitrojs/nitro/blob/8c2a2d8589a1c65b091f8bce1ca25d756f25bb11/src/utils/compress.ts#L17
compressPublicAssets is opening all assets at the same time. https://github.com/nitrojs/nitro/pull/2458 solves a similar problem by limiting concurrency. I believe a similar approach can be used here to fix the issue.
Additional context
No response
Logs
02:37:44.039 ⚙ Preparing app for cloudflare-module...
02:37:45.682 [error] EMFILE: too many open files, open '/opt/buildhome/repo/.output/public/_build/assets/ibm-plex-sans-latin-ext-700-italic-BKA4l2Ci.woff2'
02:37:45.683 at async open (node:internal/fs/promises:638:25)
02:37:45.683 at async Object.readFile (node:internal/fs/promises:1238:14)
02:37:45.683 at async node_modules/.pnpm/nitropack@2.11.12_xml2js@0.6.2/node_modules/nitropack/dist/core/index.mjs:1690:28
02:37:45.683 at async Promise.all (index 1001)
02:37:45.683 at async compressPublicAssets (node_modules/.pnpm/nitropack@2.11.12_xml2js@0.6.2/node_modules/nitropack/dist/core/index.mjs:1683:3)
02:37:45.683 at async copyPublicAssets (node_modules/.pnpm/nitropack@2.11.12_xml2js@0.6.2/node_modules/nitropack/dist/core/index.mjs:1922:5)
02:37:45.683 at async createBuild (node_modules/.pnpm/vinxi@0.5.6_@types+node@22.15.24_db0@0.3.2_ioredis@5.6.1_jiti@2.4.2_lightningcss@1.30.1_sass@_mzhkbpwibqfcgna6zocrmkwzxy/node_modules/vinxi/lib/build.js:332:2)
02:37:45.683 at async Object.run (node_modules/.pnpm/vinxi@0.5.6_@types+node@22.15.24_db0@0.3.2_ioredis@5.6.1_jiti@2.4.2_lightningcss@1.30.1_sass@_mzhkbpwibqfcgna6zocrmkwzxy/node_modules/vinxi/bin/cli.mjs:245:5)
02:37:45.683 at async runCommand (node_modules/.pnpm/citty@0.1.6/node_modules/citty/dist/index.mjs:316:16)
02:37:45.683 at async runCommand (node_modules/.pnpm/citty@0.1.6/node_modules/citty/dist/index.mjs:307:11)
02:37:45.683
02:37:45.683 [error] EMFILE: too many open files, open '/opt/buildhome/repo/.output/public/_build/assets/ibm-plex-sans-latin-ext-700-italic-BKA4l2Ci.woff2'
02:37:45.711 ELIFECYCLE Command failed with exit code 1.
02:37:45.746 Failed: error occurred while running build command
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with src/utils/compress.ts at the compressPublicAssets function and inspect how it opens assets concurrently. Compare the approach with pull request #2458, which addresses a similar concurrency problem. Done means compressing public assets without exceeding the open-file limit during builds.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- nodejs, typescript
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100