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_map may acidentally bind over large values #94

Closed
josevalim opened this issue Oct 29, 2019 · 0 comments · Fixed by #95
Closed

json_map may acidentally bind over large values #94

josevalim opened this issue Oct 29, 2019 · 0 comments · Fixed by #95

Comments

@josevalim
Copy link
Contributor

So json_map today has a flaw in that it creates a closure and that can accidentally close over a large objects. For example, Nebo15/logger_json library does this:

https://github.com/Nebo15/logger_json/blob/e041318e496affdfc44226c33dac38e98a37695a/lib/logger_json/plug/metadata_formatters/google_cloud_logger.ex#L23

Since conn.method is being passed to json_map, a closure pointing to conn will be created. Then the whole conn is sent to the Logger process, which may cause spikes in memory usage.

The fix is logger_json is simple but, since json_map is somewhat changing the semantics of the code, it may be worth fixing it in Jason instead?

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 a pull request may close this issue.

1 participant