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

pmx.emit('label', object) modifies object. #14

Closed
dkran opened this issue Apr 13, 2015 · 4 comments
Closed

pmx.emit('label', object) modifies object. #14

dkran opened this issue Apr 13, 2015 · 4 comments
Assignees

Comments

@dkran
Copy link

dkran commented Apr 13, 2015

I was trying to use pmx.emit to log out customer onboards before they are inserted into my database.
I have json filtering in place so I can insert my req.body directly into the database. I was just doing pmx.emit('customer:creation', req.body), then inserting it into my database. This fails. If I remove pmx.emit from the equation, it succeeds. somehow simply logging the object is modifying the object. Bad mojo.

https://github.com/keymetrics/pmx/blob/master/lib/events.js#L14

This is our offending line of code, it apparently appends an __name as the event name to the object, but why is that necessary? Wouldn't it posit that these objects would be reused later possibly?

@Unitech
Copy link
Member

Unitech commented Apr 13, 2015

We should use json-stringify-safe module to avoid this behaviour

@dkran
Copy link
Author

dkran commented Apr 13, 2015

So I should just stringify that object huh? Okay my mistake.

@jorge-d jorge-d self-assigned this Apr 14, 2015
@Unitech
Copy link
Member

Unitech commented May 28, 2015

fixed

@Unitech Unitech closed this as completed May 28, 2015
@dkran
Copy link
Author

dkran commented May 28, 2015

Thank you.

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

No branches or pull requests

3 participants