Git Product home page Git Product logo

hello-cls's People

Contributors

dependabot[bot] avatar heiso avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

hello-cls's Issues

The example in the "How to use" section of the README.md is no longer true

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:

  1. Calling 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 context
  2. Calling context.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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.