Closed kmkr closed 9 years ago
No... I think we just need more recursion!
Could you share more details about how you're using wiredep, Node version, wiredep version, etc. and then steps to reproduce?
Sorry for my smart-alec response. Was playing video games. Serious response this time:
I think most important would be your bower.json
so that we can see if it gives us a call stack error.
What package do we think has the cyclical dependecy? From looking at the error, it looks like lodash
depends on lodash
...? That can't be right.
Happy to look into this if you can give us a bit more details about how to reproduce.
:+1: I'm currently running into this issue. Here's my log:
events.js:85
throw er; // Unhandled 'error' event
^
RangeError: Maximum call stack size exceeded
at /Users/dwilt/Projects/Tourrs/tourrs/node_modules/wiredep/lib/detect-dependencies.js:145:29
at forOwn (/Users/dwilt/Projects/Tourrs/tourrs/node_modules/wiredep/node_modules/lodash/dist/lodash.js:2106:15)
at Function.forEach (/Users/dwilt/Projects/Tourrs/tourrs/node_modules/wiredep/node_modules/lodash/dist/lodash.js:3303:9)
at /Users/dwilt/Projects/Tourrs/tourrs/node_modules/wiredep/lib/detect-dependencies.js:181:11
at forOwn (/Users/dwilt/Projects/Tourrs/tourrs/node_modules/wiredep/node_modules/lodash/dist/lodash.js:2106:15)
at Function.forEach (/Users/dwilt/Projects/Tourrs/tourrs/node_modules/wiredep/node_modules/lodash/dist/lodash.js:3303:9)
at /Users/dwilt/Projects/Tourrs/tourrs/node_modules/wiredep/lib/detect-dependencies.js:181:11
at forOwn (/Users/dwilt/Projects/Tourrs/tourrs/node_modules/wiredep/node_modules/lodash/dist/lodash.js:2106:15)
at Function.forEach (/Users/dwilt/Projects/Tourrs/tourrs/node_modules/wiredep/node_modules/lodash/dist/lodash.js:3303:9)
at /Users/dwilt/Projects/Tourrs/tourrs/node_modules/wiredep/lib/detect-dependencies.js:181:11
Node: v0.12.0
It's failing (sometimes) when I run wiredep
along with other tasks but works every time when I run it standalone. For example, this works:
gulp index
and here's my task:
gulp.task('index', function() {
return gulp.src(paths.app + 'index.jade')
.pipe(jade({
pretty: true
}))
.pipe(wiredep({
ignorePath: '../bower_components/',
exclude: [
'bower_components/angular/angular.js',
'angular-animate.js',
'angular-sanitize.js',
'angular-ui-router.js'
],
fileTypes: {
html: {
replace: {
js: '<script src="lib/{{filePath}}"></script>'
}
}
}
}))
.pipe(gulp.dest(paths.dist));
});
but this sometimes fails..
gulp build
gulp.task('build', function(callback) {
runSequence(
'clean',
['assets', 'templates', 'styles', 'scripts'],
'index',
callback);
});
Here's my bower.json
:
{
"name": "myApp",
"private": "true",
"dependencies": {
"ionic": "driftyco/ionic-bower#1.0.0-rc.1",
"ion-affix": "~1.0.0",
"animate.css": "~3.3.0",
"angular-bootstrap": "~0.13.0",
"ng-multi-transclude": "~0.1.5",
"ngCordova": "~0.1.14-alpha",
"angular-translate": "~2.7.0",
"pouchdb": "~3.6.0",
"lodash": "~3.10.0",
"parse": "~1.5.0",
"material-design-iconic-font": "~2.1.1",
"meyer-reset": "*"
},
"overrides": {
"ionic": {
"main": [
"/scss/ionic.scss",
"./js/ionic.bundle.js"
]
}
}
}
Here's my package.json
:
{
"name": "myApp",
"repository": "",
"license": "ISC",
"version": "1.0.0",
"description": "myApp: An Ionic project",
"dependencies": {
"gulp": "^3.5.6",
"gulp-concat": "^2.2.0",
"gulp-minify-css": "^0.3.0",
"gulp-rename": "^1.2.0",
"gulp-sass": "^0.7.1",
"parse": "^1.3.5",
"pouchdb": "^3.4.0"
},
"devDependencies": {
"bower": "^1.3.3",
"del": "^1.2.0",
"gulp-autoprefixer": "^2.3.0",
"gulp-babel": "^5.1.0",
"gulp-htmlmin": "^1.1.3",
"gulp-inject": "^1.5.0",
"gulp-jade": "^1.0.1",
"gulp-ng-templates": "0.0.6",
"gulp-shell": "^0.4.2",
"gulp-useref": "^1.2.0",
"gulp-util": "^2.2.14",
"gulp-webpack": "^1.5.0",
"jasmine-core": "^2.2.0",
"karma": "^0.12.31",
"karma-chrome-launcher": "^0.1.7",
"karma-jasmine": "^0.3.5",
"karma-webpack": "^1.5.0",
"main-bower-files": "^2.9.0",
"run-sequence": "^1.1.2",
"shelljs": "^0.3.0",
"wiredep": "^2.2.2",
"wrench": "^1.5.8"
},
"cordovaPlugins": [
"org.apache.cordova.camera",
"org.apache.cordova.file"
],
"cordovaPlatforms": [
"ios"
]
}
Could you share more details about how you're using wiredep, Node version, wiredep version, etc. and then steps to reproduce?
- node 0.12.2
- wiredep 2.2.2
What package do we think has the cyclical dependecy?
In my case, we have our own non-public repository so I'm unable to give you a bower.json
without finding public packages that has a cyclical dependency graph. So, instead consider this case:
P1
depends on P2
P2
depends on P1
The root cause for the problem is that the packages is configured incorrectly and should be fixed. We did this as soon as we understood the problem. However, this is not obvious by the stack overflow error and an improvement in wiredep
is:
I think 1) is better since it requires the root cause to be fixed instead of accepting the error. I also believe case 1) is easier to implement as I suspect 2) may have some deviations.
From looking at the error, it looks like lodash depends on lodash...? That can't be right.
I believe lodash being in the stack trace is simply because the library is used to wrap forEach
loops, and some callback inside the _.forEach
fills up the stack.
The root cause for the problem is that the packages is configured incorrectly and should be fixed. We did this as soon as we understood the problem.
I've done this twice already, thankfully finding this issue both times and realizing I had just introduced a cyclical dependency.
Quick :+1:, so @kmkr knows he's not alone.
Should handle cyclical dependencies and warn instead of failing with call stack exceeded-error.