We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
i'm creating a package and use cls-hooked to keep the request in the context in hapi.js
1- i created the function to start context
let createNamespace = require('cls-hooked').createNamespace; const ns = createNamespace('test'); bindCurrentNamespace(req, reply) { ns.bindEmitter(req); ns.run(() => { reply() }); }
2- another functions to set and get value
setCurrentContext(req, reply) { ns.set('test', 'test'); reply(); } getCurrentContext() { return ns.get('test'); }
when i'm using these functions in async waterfall i lost the context in the second callback
async.waterfall( [ function(cb) { getCurrentContext(); // return 'test' getTest(cb); }, function(testData, cb1) { getCurrentContext(); // return undefined getTest2(testData, (err, data) => { callback(err, data); }); } ], callback );
i tried to console the namespace to check if it keep the same namespace or not i checked it like that
let ns = getNamespace(); async.waterfall( [ function(cb) { console.log(ns); getCurrentContext(); // return 'test' getTest(cb); }, function(testData, cb1) { console.log(ns); getCurrentContext(); // return undefined getTest2(testData, (err, data) => { callback(err, data); }); } ], callback );
what i found is:
ns
Namespace { name: 'request', active: { _ns_name: 'request', id: 1096, 'test': 'test' }, _set: [ null ], id: -1, _contexts: Map { 1120 => { _ns_name: 'request', id: 1096, 'test': 'test' }, 1121 => { _ns_name: 'request', id: 1096, 'test': 'test' } } }
Namespace { name: 'request', active: null, _set: [], id: -1, _contexts: Map {}, _indent: 0 }
i found namespace.exit(context); in line 412 in context.js file this line exit the context before the callback Done
namespace.exit(context);
but when i removed it all requests overwrite each other
anyone have idea how to fix this issue?
The text was updated successfully, but these errors were encountered:
@Jeff-Lewis do you have idea why this issue happen?
Sorry, something went wrong.
No branches or pull requests
i'm creating a package and use cls-hooked to keep the request in the context in hapi.js
1- i created the function to start context
2- another functions to set and get value
when i'm using these functions in async waterfall i lost the context in the second callback
i tried to console the namespace to check if it keep the same namespace or not i checked it like that
what i found is:
ns
like thatns
like thati found
namespace.exit(context);
in line 412 in context.js file this line exit the context before the callback Donebut when i removed it all requests overwrite each other
anyone have idea how to fix this issue?
The text was updated successfully, but these errors were encountered: