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
760 stars 89 forks source link

Why persist namespaces globally? #25

Closed bruceharris closed 6 years ago

bruceharris commented 6 years ago

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

Jeff-Lewis commented 6 years ago

@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?

bruceharris commented 6 years ago

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.