Open
Description
Async-listener will propagate contexts through Promise.all, which is different behavior from similar functionality in the domain module.
It's not 100% clear to me that this is a bug, though it is unexpected.
Test case:
'use strict';
// CLS
(() => {
const cls = require('continuation-local-storage');
const ns = cls.createNamespace('ns');
const promises = [];
for (let i=0; i < 3; i++) {
const p = new Promise((resolve) => {
ns.run(() => {
ns.active.i = i;
resolve(i)
});
});
promises.push(p);
}
Promise.all(promises)
.then(() => {
console.log('[CLS] Promise.all active ns', ns.active);
});
})();
// domain
(() => {
const domain = require('domain');
const d = domain.createDomain();
const promises = [];
for (let i=0; i < 3; i++) {
const p = new Promise((resolve) => {
d.run(() => {
domain.active.i = i;
resolve(i);
});
});
promises.push(p);
};
Promise.all(promises)
.then(() => {
console.log('[Domain] Promise.all active domain', d.active);
});
})();
Output:
$ node -version
v6.2.2
$ node cls-test.js
[CLS] Promise.all active ns { i: 2 }
[Domain] Promise.all active domain undefined
Metadata
Metadata
Assignees
Labels
No labels