react: Error: EMFILE: too many open files
Moving from “phosphor-react” to “@phosphor-icons/react”, I’ve got the following issues when deploying on Vercel in a Nextjs application:
[Error: EMFILE: too many open files, open '/var/task/node_modules/@phosphor-icons/react/dist/icons/SidebarSimple.es.js'] {
errno: -24,
code: 'EMFILE',
syscall: 'open',
path: '/var/task/node_modules/@phosphor-icons/react/dist/icons/SidebarSimple.es.js',
page: '/guides'
}
RequestId: 2c953896-3cf8-4f3a-8bb0-86de2ca6662c Error: Runtime exited with error: exit status 1
Runtime.ExitError
I’m still using the /pages directory, haven’t moved to /app yet in my codebase.
Tried to upgrade my Node server from v16 to v18, no luck.
SidebarSimple is not even used in my code.
Looks like it’s bugging when I need to check the auth state with NextAuthjs. So perhaps there’s a conflict with the signIn and signOut methodes from this other library, as I can see a lot of similar errors in my logs.
Let me know if I can bring more context.
About this issue
- Original URL
- State: open
- Created a year ago
- Reactions: 13
- Comments: 28 (6 by maintainers)
Commits related to this issue
- https://github.com/phosphor-icons/react/issues/45#issuecomment-1773840947 — committed to Prototypr/prototypr-frontend by GraemeFulton 5 months ago
I can confirm that this error is still present, if you try to import more icons at once. (“next”: “^13.5.6”, “@phosphor-icons/react”: “^2.0.13”)
The modularizeImports fix above is no longer working with the newest version, since the icons are now in different folders.
@phosphor-icons/react/dist/csr/{{member}}and@phosphor-icons/react/dist/ssr/{{member}}So in order to make it work you need to change it to this:
I was also using styled-components in my code and it was still throwing errors when I tried to style the icons (icon was undefined). So I also had to import the icon this way.
But you would need to import all your icons this way, which is not rly fun. So its easier to use the experimental code and hope that it wont fail.
It looks like Nextjs 13.5 added optimizations specifically for this problem (large component/icon libraries with many files). The
modularizeImportsobject is should be replaced withoptimizePackageImports: [...pkg names], and the bundler will automagically transform them into the respective submodule imports, in a more efficient way than before.I managed to solve this problem using the modularizeImports feature from next like mentioned above, but the path for the icons is either incorrect in the
package.jsonor for the types in TypeScript.But it works with
import Icon from "@phosphor-icons/react/Icon";While TypeScript says the path should be
import Icon from "@phosphor-icons/react/dist/icons/Icon";Solution is to add the following property in your next config file:
And then you can use the imports normally and next will take care to modularize the imports for you.
Confirming @rektdeckard’s find - we updated to NextJS 13.5.3 and the
modularizeImportsapproach wasn’t compiling, and we were getting the too many open files crash. The following in next.config.js fixed it:Getting this same error with a Vite + Remix app deployed to vercel. I’ve determined just importing a single icon causes the EMFILE errors in Vercel. I don’t have access to “optimizePackageImports” since this is a remix+vite app.
I don’t have too much helpful to add for others - importing the icons like
import { CaretDown } from "@phosphor-icons/react/dist/csr/CaretDown"does resolve the issues. So for now we’ve migrated our codebase to direct imports like this.I’m having the same issue:
i had to switch from
@phospor-icons/reacttophosphor-reactand now it’s working fine.Hey gang. The paths for the icons were correct, but the typings did not account for the aliasing we do in the
exportsfield inpackage.json. I have pushed a v2.0.8 build thatmainfield, so the lib should be comprehensible to CJS environments.I recommend using the full /dist/icons/Foo paths all the same, if you plan on using modular imports.
I would love to hear if this fixes things for you.