Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read property pm2_env of undefined #2870

Closed
tnguyen14 opened this issue May 9, 2017 · 16 comments
Closed

Cannot read property pm2_env of undefined #2870

tnguyen14 opened this issue May 9, 2017 · 16 comments

Comments

@tnguyen14
Copy link

tnguyen14 commented May 9, 2017

Hi,

I'm trying to use pm2 inside a docker container (it works fine on the host machine), and I am getting this error:

:; docker logs test                                                                                                                                                                                                                                            
/src/node_modules/pm2/lib/API.js:995
        Common.printOut(conf.PREFIX_MSG + 'App [%s] launched (%d instances)', data[0].pm2_env.name, data.length);
                                                                                     ^
TypeError: Cannot read property 'pm2_env' of undefined
    at /src/node_modules/pm2/lib/API.js:995:86
    at /src/node_modules/pm2-axon-rpc/lib/client.js:45:10
    at Parser.<anonymous> (/src/node_modules/pm2-axon/lib/sockets/req.js:67:8)

I tried to look this up, and it seems that data is msg.args from the socket? I'm not sure what this is, or how to debug it further.

Is there anything I could do to figure out this issue further?

@vmarchaud
Copy link
Contributor

PM2/NodeJS version ?

@Unitech
Copy link
Owner

Unitech commented May 10, 2017

Which Docker image are you using also?

@Unitech Unitech added the T: Bug label May 10, 2017
@tnguyen14
Copy link
Author

Node version 6.10.1
pm2 version 2.1.4
It is a custom image that is built off of RHEL 7.3

@tnguyen14
Copy link
Author

tnguyen14 commented May 10, 2017

I just updated to pm2 version 2.4.6, and I am getting the same error.

:; docker logs test
/src/node_modules/pm2/lib/API.js:1031
        Common.printOut(conf.PREFIX_MSG + 'App [%s] launched (%d instances)', data[0].pm2_env.name, data.length);
                                                                                     ^
TypeError: Cannot read property 'pm2_env' of undefined
    at /src/node_modules/pm2/lib/API.js:1031:86
    at /src/node_modules/pm2-axon-rpc/lib/client.js:45:10
    at Parser.<anonymous> (/src/node_modules/pm2-axon/lib/sockets/req.js:67:8)

@tnguyen14
Copy link
Author

I think this might have to do with having a out_file and error_file property declared, though I haven't been able to completely isolate and reproduce that yet.

@Jasonbit
Copy link

Same error - totally killed a deploy for me today.

Node 7.10.0
pm2 2.4.6

Going to try to revert back to diff version(s)..

@vmarchaud
Copy link
Contributor

Published under PM2 2.5

@andyfleming
Copy link
Contributor

@tnguyen14 I think it may have to do with if the log file specified is accessible/writeable. That's what appeared to have solve the issue for me.

@Unitech
Copy link
Owner

Unitech commented Jun 23, 2017

confirmed, it has been fixed. you can try the fix:

$ npm install Unitech/pm2#development -g
$ pm2 update

@zachariahtimothy
Copy link

@andyfleming can you confirm what you did to fix this? I am using the latest docker container and it is still an issue.

@ivoribeiro
Copy link

Same here

@andyfleming
Copy link
Contributor

To be honest, I can't remember what project I was working on where I ran into this, but I believe what solved the issue for me was reconfiguring the log settings (because the process didn't have permission to write logs where it was trying to).

If you use a processes.json config file to start your processes, try making sure you are sending errors/logs to stdout + stderr.

{
  "apps" : [{
     //...
     "error_file": "/dev/stderr",
     "out_file": "/dev/stdout",
    //...
  }]
}

@vmarchaud
Copy link
Contributor

Could you share the exact error you have ? @ivoribeiro @zachariahtimothy
Last version may have the same error but not the same lines (check here), it would be easier to pinpoint the problem with it

@zachariahtimothy
Copy link

zachariahtimothy commented Oct 23, 2017

@andyfleming thanks I tried that with the same error.
@vmarchaud I am receiving the following:

/usr/local/lib/node_modules/pm2/lib/binaries/Runtime4Docker.js:94
var pm_id = obj[0].pm2_env.pm_id;
^

TypeError: Cannot read property 'pm2_env' of undefined
at /usr/local/lib/node_modules/pm2/lib/binaries/Runtime4Docker.js:94:26
at /usr/local/lib/node_modules/pm2/lib/API.js:1009:21
at /usr/local/lib/node_modules/pm2/lib/API.js:1080:19
at /usr/local/lib/node_modules/pm2/node_modules/async/dist/async.js:421:16
at replenish (/usr/local/lib/node_modules/pm2/node_modules/async/dist/async.js:941:25)
at iterateeCallback (/usr/local/lib/node_modules/pm2/node_modules/async/dist/async.js:931:17)
at /usr/local/lib/node_modules/pm2/node_modules/async/dist/async.js:906:16
at /usr/local/lib/node_modules/pm2/lib/API.js:1046:16
at /usr/local/lib/node_modules/pm2/node_modules/async/dist/async.js:3083:16
at replenish (/usr/local/lib/node_modules/pm2/node_modules/async/dist/async.js:946:17)

@nkostic
Copy link

nkostic commented Oct 23, 2017

Hi @zachariahtimothy I had very similar error. Please make sure that you app.js file is in the expected location.

@pukapukan
Copy link

I came across the same error - turns out I had a typo in the args for pm2-docker.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants