JsCommunity / JsCommunity/node-zone
There is a problem. If node-zone include node-zone, the outside will be replaced by the last child zone data.
Open
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 2
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Description
const {current} = require('node-zone');
let zone = current.fork('my zone');
zone.data = {test: 'test'};
zone.run(async () => {
let __current = require('node-zone').current;
console.log(__current);
for (let i = 0; i < 50; i++) {
(async function (i) {
let zone = current.fork('my zone ' + i);
zone.data = {i: i};
// zone.run()
// zone.set('i', 123456);
// console.log(current);
zone.run(async () => {
(async function () {
(async function () {
(async function () {
let {current} = require('node-zone');
// console.log(common.timeHelper.format_ms(), current);
console.log(current);
})();
})();
})();
});
})(i);
}
//will lost the current, will show the last child zone data.
console.log('current zone data', __current);
console.log('last child zone data', require('node-zone'));
});
return;
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the reproduction in the issue and inspect the node-zone implementation of current, fork, and run. Reproduce the nested asynchronous calls, then trace why the outer zone is replaced by the last child zone; done means the outer current still has its original data after the child zones finish.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100