Closed wuhw closed 6 years ago
const { createNamespace, getNamespace } = require('continuation-local-storage'); const ns = createNamespace('test'); ns.run(async () => { ns.set('value', 1); console.log(ns.get('value')); await asyncfun(); console.log(ns.get('value')); }); function asyncfun() { return Promise.resolve(); } //got 1 undefined
CLS does not support async/await. You can try cls-hooked. Side note though: async/await support in async_hooks is currently broken in Node.js 10.