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

JSON.stringify() container cradle results in memory leak because of cyclic references #153

Merged
merged 3 commits into from
Nov 25, 2019

Conversation

berndartmueller
Copy link
Contributor

Winston, sentry, and many more libraries, which call internally JSON.stringify or some other (custom) function for JSON serialization, cause a memory leak when passed a container cradle.

I especially had the case together with Sequelize and winston json formatter. For some reason, sometimes (mostly in case of errors) it tried to log the whole container cradle. This took forever and resulted in a silent app crash which was not immediately traced back to the problems roots.

This PR simply checks if the container cradle was called via JSON.stringify by checking for toJSON and returns a simple string.

Following github issues are connected to this:
coopernurse/node-pool#275
sequelize/sequelize#10443

Thanks!

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 7849bf4 on findheim:feat-cradle-toJSON into ab5c033 on jeffijoe:master.

@jeffijoe jeffijoe merged commit 8fd4a2a into jeffijoe:master Nov 25, 2019
@jeffijoe
Copy link
Owner

Thanks! Released as v4.2.3! 🎉

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

Successfully merging this pull request may close these issues.

3 participants