Skip to content
This repository has been archived by the owner on May 4, 2022. It is now read-only.

Commit

Permalink
Less precise error message for dependency loop, because the dependenc…
Browse files Browse the repository at this point in the history
…y loop detection is not absolutely precise. (MAX_TRAVERSAL can be hit while traversing a 'spur' of a dependency loop.)
  • Loading branch information
raymond-lam committed Nov 27, 2016
1 parent 1d95585 commit 247f86d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion require.js
Expand Up @@ -756,8 +756,9 @@ function _resolveTree(args) {
// If we've traversed an unreasonable number of nodes, there's probably a cycle.
if (++numberOfTraversedNodes > MAX_TRAVERSAL) {
throw new Error(
'Traversed too many nodes in the dependency tree. Possible cycle at '
'Traversed too many nodes in the dependency tree. Possible cycle at module '
+ (currentNode.fullModulePath || currentNode.modulePath)
+ ' or at a related module.'
);
}
}
Expand Down
4 changes: 2 additions & 2 deletions test/test.js
Expand Up @@ -970,7 +970,7 @@ QUnit.test('dependency loops', function(assert) {

assert.raises(function(){
require('10-a');
}, /Traversed too many nodes in the dependency tree. Possible cycle at /, 'dependency loop throws error');
}, /Traversed too many nodes in the dependency tree. Possible cycle at module .+ or at a related module\./, 'dependency loop throws error');

define('10-d', function() { return {}; });
define('10-e', ['10-d', '10-f'], function() { return {}; });
Expand All @@ -979,7 +979,7 @@ QUnit.test('dependency loops', function(assert) {

assert.raises(function(){
require('10-e');
}, /Traversed too many nodes in the dependency tree. Possible cycle at /, 'dependency loop with other dependencies throws error');
}, /Traversed too many nodes in the dependency tree. Possible cycle at module .+ or at a related module\./, 'dependency loop with other dependencies throws error');

});

Expand Down

0 comments on commit 247f86d

Please sign in to comment.