[PM2][ERROR] Process failed to launch spawn E2BIG — [solved]

Evgenii Kozinchenko
2 min readFeb 11, 2020

--

A couple of weeks ago I ran into an unexpected problem for me. Our project has ceased to be assembled on the testing circuit. The error was a strange message:

In this article, I will tell you why this happened, and how I solved this problem.

The architecture of our project is quite complex, it consists of a large number of microservices and a Kubernetes managing this entire zoo. I dreamed about debugging for a long time and looking for a problem. It turned out that the problem is a stack overflow process.env in the Node.js, the number of allocated memory for storing global variables is allocated, and the memory volume is finite. As soon as you overflow the repository, you get this kind of error.

pm2 report ===>
E2BIG: Argument list too long; used when the arguments passed to a new program being executed with one of the exec functions

Since it was necessary to solve the problem quickly, the option to reduce the number of global variables is not acceptable for us. I did a revision to the lib, and did a simple filtering of incoming global variables.

lib/API/schema.json
lib/Common.js
lib/binaries/CLI.js

I made a pull request to the main repository of the library, but I’m not sure that they will accept it. I will be glad if you support me like =)
https://github.com/Unitech/pm2/pull/4596

But you can also use the version from my repository.

Setting up a filter is very simple. An array of parameters must be specified in the file ecosystem.config.js

I really hope that this article will save someone a lot of time and effort, thanks.

--

--