Jeff-Lewis / cls-hooked

cls-hooked : CLS using AsynWrap or async_hooks instead of async-listener for node 4.7+
BSD 2-Clause "Simplified" License
758 stars 89 forks source link

_contextId: size keeps continuing to grow, even after destroying the namespace #68

Open lioulbehailu opened 3 years ago

lioulbehailu commented 3 years ago

_contextId: size keeps continuing to grow, event after destroying the namespace. Doesn't create a Performance or a Memory leak problem when using in a production???

as you can see, i am destroying the namespace if it is not active

`app.use((req, res, next) => {

if (getNamespace('ADMIN') && getNamespace('ADMIN').active === null) {
    destroyNamespace('ADMIN')
}

if (getNamespace('user') &&getNamespace('user').active === null) {
    destroyNamespace('user');
}
next()});`

But the _contexts Map is growing in size.

May be i have misunderstand this in the wrong way, or may be not, but i think this gonna create when the server gets a request from multiple users

CLS-Hooked Issue