bugfix: try/catch around userInfo to avoid crash #3184

This commit is contained in:
vmarchaud 2017-10-03 11:13:24 +02:00
parent 6f2694876f
commit 9a2a733970

View File

@ -221,10 +221,15 @@ UX.dispAsTable = function(list, interact_infos) {
var current_user = '';
if (os.userInfo)
current_user = os.userInfo().username;
else
try {
current_user = os.userInfo().username;
} catch (err) {
// For the case of unhandled error for uv_os_get_passwd
// https://github.com/Unitech/pm2/issues/3184
current_user = '';
} else {
current_user = process.env.USER || process.env.LNAME || process.env.USERNAME || process.env.SUDO_USER || process.env.C9_USER || process.env.LOGNAME;
;
}
list.sort(function(a, b) {
if (a.pm2_env.name < b.pm2_env.name)
return -1;