"EMFILE: too many open files error" while CI/CD deploy

Hello. I have an organization with multiple nodejs lambda services. Every service have different Github repository and Ci/Cd integration. They works well until yesterday.
Yesterday, after i commited some code to one of my services, Ci/Cd deploy throwed an error. Here is my deploy logs ;

Build step: serverless deploy --stage dev --region us-east-1 --force --org myorg --app myapp --debug
Serverless: Deprecation warning: Resolution of lambda version hashes was improved with better algorithm, which will be used in next major release.
            Switch to it now by setting "provider.lambdaHashingVersion" to "20201221"
            More Info: https://www.serverless.com/framework/docs/deprecations/#LAMBDA_HASHING_VERSION_V2
Serverless: Packaging service...
Serverless: Excluding development dependencies...
Serverless: User Configuration warning: Cannot resolve local config file.
Error: EMFILE: too many open files, open '/My_Service/.serverlessrc'
Serverless: User Configuration warning: Cannot resolve global config file: /root/.serverlessrc 
Error: EMFILE: too many open files, open '/root/.serverlessrc'
Serverless: Your previous global config was renamed to /root/.serverlessrc.bak for debugging. Default global config will be recreated under /root/.serverlessrc.
 
  Serverless Error ---------------------------------------
 
  Cannot read file node_modules/string-width/node_modules/strip-ansi/index.js due to: EMFILE: too many open files, open '/My_Service/node_modules/string-width/node_modules/strip-ansi/index.js'
 
  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com
 
  Your Environment Information ---------------------------
     Operating System:          linux
     Node Version:              12.19.0
     Framework Version:         2.28.3
     Plugin Version:            4.4.3
     SDK Version:               2.3.2
     Components Version:        3.7.1
 
Build step failed: serverless deploy --stage dev --region us-east-1 --force --org myorganization --app myapp --debug

That file always changes to different file. And there are two points.

  • I can upload my code from my local with sls deploy. It works well. No problem. So i think there is no problem with my yaml file. But if anyone needs that, i can share.
  • My other services gives same error. All Ci/Cd integrasions throws same error.

I tried to clear or delete my CloudFormation Snacks and buckets. Thats not worked. Anyone help me? Im so confused.

1 Like

Having the same issue. Started this morning. @atakansavas Can you share your serverless.yaml?

Of course. I use nodejs with fastify.
Here is my file;

provider:
  httpApi:
    metrics: true
  name: aws
  runtime: nodejs12.x
  region: us-east-1
  apiGateway:
    shouldStartNameWithService: true
  vpc:
    securityGroupIds:
      - sg-***
    subnetIds:
      - subnet-***

plugins:
  - serverless-offline
  - serverless-apigw-binary

functions:
  app:
    handler: lambda.prepare
    events:
      - http: ANY /
      - http: 'ANY /{proxy+}'

custom:
  apigwBinary:
    types:
      - '*/*'

Hi again. Finally i can fix the problem. I dont know why, but when i try to deploy my lambda project to cloud, error says : my npm packages size is too big. And i decided to take a look again my package.json. Here is my solution steps;

  • Make sure which dependencies you need. Make you sure you use devDependencies.
  • individually: true flag in package helps me too.

Also, you can use serverless-bundle package on npm for webpack.

A fix for the issue related to EMFILE is being deployed later today.

2 Likes

And could it be solved?

The fix was deployed last week so you should be able to update the framework and all is well again

How have you fixed for the issue related to EMFILE?