EMFILE "too many open files" error during pnpm dependency installation with Workers

For Workers & Pages, what is the name of the domain?

there.do

What is the error number?

No specific error number - EMFILE system error

What is the error message?

EMFILE: too many open files, open ‘/opt/buildhome/repo/apps/nextjs/node_modules/bundle-require/package.yaml’

What is the issue or error you’re encountering

EMFILE “too many open files” error occurs during pnpm dependency installation in a monorepo when trying to migrate from Cloudflare Pages to Cloudflare Workers with @opennextjs/cloudflare.

What steps have you taken to resolve the issue?

  1. Verified that the nodejs_compat compatibility flag is enabled in wrangler configuration
  2. Confirmed the same codebase works fine on Cloudflare Pages deployment (and locally of course)

What are the steps to reproduce the issue?

Due to the complexity of our monorepo setup, it’s difficult to provide a minimal reproducible repository. However, the issue can be described as follows:

  1. Set up a Next.js project with @opennextjs/cloudflare in a monorepo environment with 24 workspace projects
  2. Configure the project for Cloudflare Workers deployment
  3. Have a project with substantial dependencies (3000+ packages as shown in logs)
  4. Run the deployment process which triggers pnpm install --frozen-lockfile

The EMFILE error occurs during the dependency installation phase when the system runs out of available file descriptors

We’re trying to migrate from Cloudflare Pages (next-on-pages) to Cloudflare Workers (@opennextjs/cloudflare). The exact same codebase deploys successfully on Cloudflare Pages, but fails during the dependency installation phase on Cloudflare Workers.

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.