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

env with json value not preserved #4080

Closed
FTwex opened this issue Dec 18, 2018 · 4 comments
Closed

env with json value not preserved #4080

FTwex opened this issue Dec 18, 2018 · 4 comments

Comments

@FTwex
Copy link

FTwex commented Dec 18, 2018

What's going wrong?

It seems that since the 3.2.3 release env variables set in the process file are not handled the same way.
With release <=3.2.2 if I dump my process env (pm2 env 0 for example) I have something like that:
ENV_VARIABLE_NAME={"key":"value"}

Since release 3.2.3 if I dump env I have something like that:
ENV_VARIABLE_NAME=[object Object]

This break my code because I try to do a JSON.parse on that value and it fails.

I would like to know if I'm not using pm2 env in the right way or if it's a side effect ?

@Unitech
Copy link
Owner

Unitech commented Dec 18, 2018

That's pretty exotic to pass JSON directly like that without stringifying it.
With PM2 <=3.2.2, how these variables were looking like? Strings?

@FTwex
Copy link
Author

FTwex commented Dec 18, 2018

Sorry I've made a mistake in my example
With PM2 <=3.2.2 env were like this ENV_VARIABLE_NAME='{"key":"value"}' so yes a string.

My process file is in JSON and env looks like that:
image
I guess PM2 stringified env values, as as i seen it in the PM2 source code

But it seem that in the latest release something has changed and prevent objects from being stringified

@Unitech
Copy link
Owner

Unitech commented Dec 19, 2018

I've restore the previous stringification behavior, will release it soon

@Unitech
Copy link
Owner

Unitech commented Dec 19, 2018

published

$ npm install pm2@latest -g
$ pm2 update

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

2 participants