Skip to content

Instantly share code, notes, and snippets.

@othiym23
Last active December 24, 2015 05:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save othiym23/6748219 to your computer and use it in GitHub Desktop.
Save othiym23/6748219 to your computer and use it in GitHub Desktop.
var assert = require('assert');
var cls = require('continuation-local-storage');
var Logger = require('bunyan');
var logger = new Logger({
name : 'test2',
stream : process.stdout,
level : 'trace'
});
logger.debug("This causes problems later.");
var test2 = cls.createNamespace("test2");
assert.ok(!test2.get('state'), "state should not yet be visible");
test2.run(function () {
test2.set('state', true);
assert.ok(test2.get('state'), "state should be visible");
setTimeout(
function () { assert.ok(test2.get('state'), "state should be visible"); },
100 // timeout is important for some reason
);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment