hellocomet / hello-cls Goto Github PK
View Code? Open in Web Editor NEWA Node.js library that implements Continuation-Local Storage for Node 10+
License: MIT License
A Node.js library that implements Continuation-Local Storage for Node 10+
License: MIT License
In the "How to use" section of the README.md file, it provides the following example code:
const { namespace } = require('hello-cls')
const context = namespace.initContext()
// I can set a value to a given key on the namespace
namespace.set('beer', ๐บ)
// I can get a value from the namespace
console.log(namespace.get('beer'))
// -> ๐บ
context.close()
// I can't get a value from the namespace if the context is closed
console.log(namespace.get('beer'))
// -> null
However, with the latest version of the code (1.0.4), calling namespace.get('beer')
after calling context.close()
actually returns '๐บ' instead of null.
I believe the root cause is the combination of two things that the code is doing:
context.close()
removes the associated async ids from the namespace map, but it does not clean out the internal store
map, so these values are still retrievable by any code that still has a handle on the contextcontext.close()
does not set the _currentContext in the namespace object to null if this context is the object that _currentContext is currently pointing to. Failing to do this allows access to the closed context object via the namespace object within the same async process.The combination of the above two conditions is causing the example to fail. Changing either ought to make the example code true again. It may be desirable to change both though.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.