hapijs / good

hapi process monitoring
Other
525 stars 161 forks source link

Configuring a reporter as an empty array create a memory leak #534

Closed ianwsperber closed 7 years ago

ianwsperber commented 7 years ago

Though obviously an edge case, if a reporter configuration is set to an empty array (essentially blank) then good will write all log messages for that reporter to a stream that is never emptied, resulting in a memory leak. From what I can tell this is due to the check here https://github.com/hapijs/good/blob/master/lib/monitor.js#L128, which should add the NoOp stream according to the condition streamObjs.length <= 1, not streamObjs.length === 1.

I discovered this problem when I configured a dev mode only reporter, which in my confidence file was achieved by setting the reporter to an empty array. It was only in production that enough logs were generated to make the leak evident.

I am putting together a PR for this issue presently. However I will need to confirm this fixes the memory leak prior to creating the PR.

arb commented 7 years ago

Yeah that sounds right to me. Though I wouldn't technically call it a memory leak... more like a out of bounds buffer?

lock[bot] commented 4 years ago

This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.