sematext / winston-logsene

Winston Transport for Logsene
http://sematext.com/logsene
Apache License 2.0
13 stars 6 forks source link

Major memory leak and crash because of "flat" dependency #21

Closed danielkcz closed 3 years ago

danielkcz commented 5 years ago

See https://github.com/hughsk/flat/issues/86

Apparently, that library is not maintained anymore, so it's probably a good idea to look for an alternative which doesn't suffer from such issues.

megastef commented 5 years ago

When does it happen? Are there cyclic object references?

danielkcz commented 5 years ago

It's possible, I tried logging a whole "request" object which might be fairly big I suppose. Not doing that anymore and everything works nicely.

I am running that app in Heroku which has limited memory usage to 512MB. In default configuration the app won't even crash like that, but Heroku will kill it when the quota is exceeded. I had to run the app like this so it can crash on its own and show the actual problem...

node --optimize_for_size --max_old_space_size=460 lib/main.js

I mean it wasn't easy to find a culprit like that. There should be some safeguards against it imo.

sznowicki commented 3 years ago

Confirm this issue.

Also tried to log with some supertest error object that apparently has circular references which makes entire app go into an infinite loop of allocating data.

I guess a workaround would be to JSON.parse(JSON.stringify(error)).

adnanrahic commented 3 years ago

Hi @FredyC @sznowicki ! I replaced the flat dep with safe-flat instead. The memory leak is fixed now. Install the latest version of winston-logsene (npm i winston-logsene@2.1.0) to include the fix. Or just run npm i winston-logsene@latest. Thanks again for raising this issue. :rocket:

danielkcz commented 3 years ago

Thank you @adnanrahic. Unfortunately, I no longer work on a project using Logsene, so I can't really enjoy the fix :)