aws / aws-xray-sdk-node

The official AWS X-Ray SDK for Node.js.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

memory leaks caused by cls-hooked

regevbr opened this issue · comments

Hi,

We noticed a massive memory leak when using this library. We managed to find that the memory leaks come from the unmaintained cls-hooked library.
Since we are using the library in manual mode, we don't even want it to be used, but currently, you create a namespace by default. When setting manual mode, the namespace gets deleted, but cls-hooks doesn't do that properly, creating a memory leak.

A proposed solution will be to not use cls if an env variable exists to control manual mode.

PR with the fix is submitted

fwiw there is an open issue that couldn't be reproduced by AWS. Hopefully they will investigate now that there are multiple reports of the issue w/ the cls-hooked library.

When setting manual mode, the namespace gets deleted, but cls-hooks doesn't do that properly, creating a memory leak.

Issues on cls-hooked repo regarding this specific memory leak for reference and tracking:
Jeff-Lewis/cls-hooked#66
Jeff-Lewis/cls-hooked#67
Jeff-Lewis/cls-hooked#68