Jeff-Lewis / cls-hooked

cls-hooked : CLS using AsynWrap or async_hooks instead of async-listener for node 4.7+

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Why persist namespaces globally?

bruceharris opened this issue · comments

Hi, I'm struggling to understand the motivation for persisting namespaces globally (by setting process.namespaces) (covered by tests tests here), as opposed to keeping that state local to the library (say, by defining a namespaces object at the top of context.js).

Thanks,
Bruce

@bruceharris good question. It was taken from othiym23/node-continuation-local-storage and not changed. There might have been a use case for it that I'm not aware of now. cls-hooked tries to be compatible with the original fork.

What's your case for removing namespaces from global?

Got it, thanks, that's helpful. Don't have a particular case for removing it, but I was trying to wrap my head around the codebase and it seemed odd/surprising and couldn't understand the motivation for that choice. Seems invasive to mutate the process object. Thought there might have been some reason that was necessary that I didn't understand, but seems it's just about backward compatibility here. Thanks again for the prompt reply.