Should tearDown be queued on process.nextTick?
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 25/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- javascript
- 領域
- testing
調査の方向性
レポートに示されている async.auto と async.parallel の fixture を使って問題を再現し、その後、wrapTest とその teardown 処理の周辺にある nodeunit/lib/core.js を調査してください。非同期コールバックに対する tearDown の順序を確認し、tearDown が完了する前に完了済みのテストがクリーンアップ済みの状態へアクセスしなくなっていることを確認してください。
索引モデルが issue の本文から書いたものです。
説明
I've encountered an issue that's reproducible with async.parallel/auto and nodeunit.
var async = require('async');
var str;
exports.setUp = function(cb){
console.log('setup');
str = "This is a test";
cb();
}
exports.tearDown = function(cb){
//process.nextTick(function(){
console.log('teardown');
str = undefined;
cb();
//});
}
exports["testA"] = function(test){
async.auto({
test1:function(cb, results){
console.log('test1');
cb(new Error("test"));
},
test2:function(cb, results){
console.log('test2');
console.log(str, str.length);
cb();
}
}, function(err, results){
if(err) console.error(err);
test.done();
});
}
exports["testB"] = function(test){
async.parallel({
test1:function(cb, results){
console.log('test1');
cb(new Error("test"));
},
test2:function(cb, results){
console.log('test2');
console.log(str, str.length);
cb();
}
}, function(err, results){
if(err) console.error(err);
test.done();
});
}
This produces the output:
setup
test1
[Error: test]
teardown
test2
teardown
✖ testATypeError: Cannot read property 'length' of undefined
at Array.exports.testA.async.auto.test2 as 0
at async.auto (/Users/davefenster/node_modules/async/lib/async.js:406:38)
at Array.forEach (native)
at _forEach (/Users/davefenster/node_modules/async/lib/async.js:26:24)
at Object.async.auto (/Users/davefenster/node_modules/async/lib/async.js:382:9)
at Object.exports.testA (/Users/davefenster/temp/testnodeunitbug/test.js:19:8)
at wrapTest (/Users/davefenster/node_modules/nodeunit/lib/core.js:231:20)
at _asyncMap (/Users/davefenster/node_modules/nodeunit/deps/async.js:163:13)
at async.forEachSeries.iterate (/Users/davefenster/node_modules/nodeunit/deps/async.js:126:25)
at _asyncMap (/Users/davefenster/node_modules/nodeunit/deps/async.js:160:17)setup
test1
[Error: test]
teardown
test2
teardown
✖ testATypeError: Cannot read property 'length' of undefined
at Array.exports.testA.async.auto.test2 as 0
at async.auto (/Users/davefenster/node_modules/async/lib/async.js:406:38)
at Array.forEach (native)
at _forEach (/Users/davefenster/node_modules/async/lib/async.js:26:24)
at Object.async.auto (/Users/davefenster/node_modules/async/lib/async.js:382:9)
at Object.exports.testA (/Users/davefenster/temp/testnodeunitbug/test.js:19:8)
at wrapTest (/Users/davefenster/node_modules/nodeunit/lib/core.js:231:20)
at _asyncMap (/Users/davefenster/node_modules/nodeunit/deps/async.js:163:13)
at async.forEachSeries.iterate (/Users/davefenster/node_modules/nodeunit/deps/async.js:126:25)
at _asyncMap (/Users/davefenster/node_modules/nodeunit/deps/async.js:160:17)FAILURES: 2/2 assertions failed (12ms)
FAILURES: Undone tests (or their setups/teardowns):
- testB
To fix this, make sure all tests call test.done()
The error manifests itself because tearDown runs before all the async.auto and async.parallel functions have executed. Ideally, what I'd want is the tearDown to run only after async.auto/parallel are complete.
To make the tests pass, uncomment the process.nextTick line in the tearDown function.
Should nodeunit be putting tearDown on the nextTick queue all the time?
- 主要言語
- JavaScript
- スター
- 1.9k
- フォーク
- 359
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
caolan/nodeunit のほかの issue
-
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 42/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
-
難易度 5/5 1週間以上 初心者へのやさしさ 20/100
caolan/nodeunit の issue をすべて見る
似ている issue
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
ericcornelissen/depreman#591 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
NanmiCoder/dsh-agent-teams#269 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 65/100
メンテナーはふだん 1 日以内に返信
-
docs
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
idean3885/claude-ops-agent#765 ·
メンテナーはふだん 1 日以内に返信
-
docs html v6
難易度 1/5 1時間未満 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信