raineorshine / npm-check-updates

Find newer versions of package dependencies than what your package.json allows
Other
9.38k stars 326 forks source link

RangeError #124

Closed poyhsiao closed 8 years ago

poyhsiao commented 9 years ago

After updated to npm-check-updates 2.x, I cannot check global npm packages update. The following is the error message is shown after type # ncu -g

/Users/kimhsiao/.nvm/versions/node/v0.12.7/lib/node_modules/npm-check-updates/node_modules/npm/lib/ls.js:199 if (seen.indexOf(dep) !== -1) { ^ RangeError: Maximum call stack size exceeded at /Users/kimhsiao/.nvm/versions/node/v0.12.7/lib/node_modules/npm-check-updates/node_modules/npm/lib/ls.js:204:23 at Array.forEach (native) at bfsify (/Users/kimhsiao/.nvm/versions/node/v0.12.7/lib/node_modules/npm-check-updates/node_modules/npm/lib/ls.js:196:21) at bfsify (/Users/kimhsiao/.nvm/versions/node/v0.12.7/lib/node_modules/npm-check-updates/node_modules/npm/lib/ls.js:216:10) at bfsify (/Users/kimhsiao/.nvm/versions/node/v0.12.7/lib/node_modules/npm-check-updates/node_modules/npm/lib/ls.js:216:10) at bfsify (/Users/kimhsiao/.nvm/versions/node/v0.12.7/lib/node_modules/npm-check-updates/node_modules/npm/lib/ls.js:216:10) at bfsify (/Users/kimhsiao/.nvm/versions/node/v0.12.7/lib/node_modules/npm-check-updates/node_modules/npm/lib/ls.js:216:10) at bfsify (/Users/kimhsiao/.nvm/versions/node/v0.12.7/lib/node_modules/npm-check-updates/node_modules/npm/lib/ls.js:216:10) at bfsify (/Users/kimhsiao/.nvm/versions/node/v0.12.7/lib/node_modules/npm-check-updates/node_modules/npm/lib/ls.js:216:10) at bfsify (/Users/kimhsiao/.nvm/versions/node/v0.12.7/lib/node_modules/npm-check-updates/node_modules/npm/lib/ls.js:216:10) at bfsify (/Users/kimhsiao/.nvm/versions/node/v0.12.7/lib/node_modules/npm-check-updates/node_modules/npm/lib/ls.js:216:10) at bfsify (/Users/kimhsiao/.nvm/versions/node/v0.12.7/lib/node_modules/npm-check-updates/node_modules/npm/lib/ls.js:216:10) at bfsify (/Users/kimhsiao/.nvm/versions/node/v0.12.7/lib/node_modules/npm-check-updates/node_modules/npm/lib/ls.js:216:10) at bfsify (/Users/kimhsiao/.nvm/versions/node/v0.12.7/lib/node_modules/npm-check-updates/node_modules/npm/lib/ls.js:216:10) at bfsify (/Users/kimhsiao/.nvm/versions/node/v0.12.7/lib/node_modules/npm-check-updates/node_modules/npm/lib/ls.js:216:10) at bfsify (/Users/kimhsiao/.nvm/versions/node/v0.12.7/lib/node_modules/npm-check-updates/node_modules/npm/lib/ls.js:216:10)

raineorshine commented 9 years ago

Thanks for reporting. Will you provide the output from npm -g ls --depth=0 so that I can troubleshoot?

poyhsiao commented 9 years ago

Hello,

I'm using Mac and the following the information that I installed on global environment (npm -g ls --depth=0). Many thanks

`` /Users/kimhsiao/.nvm/versions/node/v0.12.7/lib

├── babel@5.8.21 ├── beefy@2.1.5 ├── bower@1.4.1 ├── coffee-script@1.9.3 ├── coffeelint@1.10.1 ├── cordova@5.1.1 ├── csslint@0.10.0 ├── eslint@1.0.0 ├── express@4.13.3 ├── express-generator@4.13.1 ├── grunt-cli@0.1.13 ├── gulp@3.9.0 ├── ionic@1.6.4 ├── ios-sim@4.1.1 ├── jade@1.11.0 ├── jshint@2.8.0 ├── jslint@0.9.3 ├── learnyounode@2.7.1 ├── learnyoureact@0.9.9 ├── mocha@2.2.5 ├── node-dependencies@0.3.1 ├── node-inspector@0.12.2 ├── node-libs-browser@0.5.2 ├── nodeclipse@0.17.2 ├── nodemon@1.4.0 ├── npm@2.11.3 ├── npm-check-updates@2.2.0 ├── npm-dep-info@1.4.0 ├── parallelshell@2.0.0 ├── phonegap@5.1.1 ├── plugman@0.23.3 ├── pm2@0.14.6 ├── react-tools@0.13.3 ├── sails@0.11.0 ├── sails-generate-backend-gulp@0.0.5 ├── sails-generate-frontend-gulp@0.1.5 ├── stream-adventure@4.0.3 ├── strongloop@5.0.0 ├── webpack@1.10.5 └── webpack-dev-server@1.10.1 ``

raineorshine commented 9 years ago

Able to reproduce. It's one of the last 10... will investigate further.

raineorshine commented 9 years ago

Never mind... after installing and uninstalling many of the packages I can't reliably reproduce. I can't tell if it is a specific package or the npm cache or something else. I'll get the error one moment, then after an uninstall and clean install of a different package, it goes away.

I'm going to need your help. If you can narrow it down to one package or provide steps to reproduce, I'll be happy to investigate further!

Kikobeats commented 9 years ago

some problem here:

ncu -g
/usr/local/lib/node_modules/npm-check-updates/node_modules/npm/lib/ls.js:196
  Object.keys(deps).forEach(function (d) {
                    ^
RangeError: Maximum call stack size exceeded
    at Array.forEach (native)
    at bfsify (/usr/local/lib/node_modules/npm-check-updates/node_modules/npm/lib/ls.js:196:21)
    at bfsify (/usr/local/lib/node_modules/npm-check-updates/node_modules/npm/lib/ls.js:216:10)
    at bfsify (/usr/local/lib/node_modules/npm-check-updates/node_modules/npm/lib/ls.js:216:10)
    at bfsify (/usr/local/lib/node_modules/npm-check-updates/node_modules/npm/lib/ls.js:216:10)
    at bfsify (/usr/local/lib/node_modules/npm-check-updates/node_modules/npm/lib/ls.js:216:10)
    at bfsify (/usr/local/lib/node_modules/npm-check-updates/node_modules/npm/lib/ls.js:216:10)
    at bfsify (/usr/local/lib/node_modules/npm-check-updates/node_modules/npm/lib/ls.js:216:10)
    at bfsify (/usr/local/lib/node_modules/npm-check-updates/node_modules/npm/lib/ls.js:216:10)
    at bfsify (/usr/local/lib/node_modules/npm-check-updates/node_modules/npm/lib/ls.js:216:10)
    at bfsify (/usr/local/lib/node_modules/npm-check-updates/node_modules/npm/lib/ls.js:216:10)
    at bfsify (/usr/local/lib/node_modules/npm-check-updates/node_modules/npm/lib/ls.js:216:10)
    at bfsify (/usr/local/lib/node_modules/npm-check-updates/node_modules/npm/lib/ls.js:216:10)
    at bfsify (/usr/local/lib/node_modules/npm-check-updates/node_modules/npm/lib/ls.js:216:10)
    at bfsify (/usr/local/lib/node_modules/npm-check-updates/node_modules/npm/lib/ls.js:216:10)
    at bfsify (/usr/local/lib/node_modules/npm-check-updates/node_modules/npm/lib/ls.js:216:10)
lkarbownik commented 9 years ago

Same here:

RangeError: Maximum call stack size exceeded at /usr/local/lib/node_modules/npm-check-updates/node_modules/npm/lib/ls.js at Array.forEach (native) at bfsify (/usr/local/lib/node_modules/npm-check-updates/node_modules/npm/lib/ls.js:196:21) at bfsify (/usr/local/lib/node_modules/npm-check-updates/node_modules/npm/lib/ls.js:216:10) at bfsify (/usr/local/lib/node_modules/npm-check-updates/node_modules/npm/lib/ls.js:216:10) at bfsify (/usr/local/lib/node_modules/npm-check-updates/node_modules/npm/lib/ls.js:216:10) at bfsify (/usr/local/lib/node_modules/npm-check-updates/node_modules/npm/lib/ls.js:216:10) at bfsify (/usr/local/lib/node_modules/npm-check-updates/node_modules/npm/lib/ls.js:216:10) at bfsify (/usr/local/lib/node_modules/npm-check-updates/node_modules/npm/lib/ls.js:216:10) at bfsify (/usr/local/lib/node_modules/npm-check-updates/node_modules/npm/lib/ls.js:216:10) at bfsify (/usr/local/lib/node_modules/npm-check-updates/node_modules/npm/lib/ls.js:216:10) at bfsify (/usr/local/lib/node_modules/npm-check-updates/node_modules/npm/lib/ls.js:216:10) at bfsify (/usr/local/lib/node_modules/npm-check-updates/node_modules/npm/lib/ls.js:216:10) at bfsify (/usr/local/lib/node_modules/npm-check-updates/node_modules/npm/lib/ls.js:216:10) at bfsify (/usr/local/lib/node_modules/npm-check-updates/node_modules/npm/lib/ls.js:216:10) at bfsify (/usr/local/lib/node_modules/npm-check-updates/node_modules/npm/lib/ls.js:216:10)

$ npm list -g --depth=0 /usr/local/lib ├── babel@5.8.23 ├── bower@1.5.2 ├── browser-sync@2.9.3 ├── devtools-terminal@0.1.3 ├── express@4.13.3 ├── express-generator@4.13.1 ├── generator@1.0.1 ├── generator-angular@0.12.1 ├── generator-angular-fullstack@3.0.0-rc7-patch.0 ├── generator-backbone@0.3.5 ├── generator-backbone-mocha@0.1.1 ├── generator-chrome-extension@0.3.1 ├── generator-express@2.8.5 ├── generator-gulp-angular@1.0.0-rc1 ├── generator-gulp-webapp@1.0.3 ├── generator-karma@1.0.0 ├── generator-mobile@2.0.0-alpha ├── generator-mocha@0.2.0 ├── generator-node-webkit@2.0.0-alpha.3 ├── generator-react-fullstack@0.1.3 ├── generator-webapp@1.0.1 ├── generator-wordpress@2.0.1 ├── grunt@0.4.5 ├── grunt-cli@0.1.13 ├── grunt-init@0.3.2 ├── gulp@3.9.0 ├── jshint@2.8.0 ├── latest-version@1.0.1 ├── mocha@2.3.2 ├── node-gyp@3.0.1 ├── node-webkit-builder@1.0.13 ├── nodemon@1.4.1 ├── npm@2.14.2 ├── npm-check-updates@2.2.1 ├── wiredep@3.0.0-beta ├── xml2json-command@0.0.2 └── yo@1.4.8

raineorshine commented 9 years ago

I am still unable to reproduce, unfortunately. If you can provide steps to reproduce, or narrow it down to a specific npm module that is causing the issue, I will investigate further.

raineorshine commented 9 years ago

It could potentially be caused by the hacky rawPromisify function I wrote because Bluebird's promisfyAll was not working on npm.commands, but it's hard to investigate without being able to reproduce.

lkarbownik commented 9 years ago

I uninstalled all modules and installed them one by one to check what causes the problem. It seems to be related to generator-mocha and all yeoman generators using mocha and generator-mocha modules (in my case, generator-backbone). I can reproduce the problem by uninstall and installing that particular module.

sidneys commented 9 years ago

Hi guys, i have the same problem. Had it for a while now - not able to use ncu since version 2+, since i mainly use it to upgrade global modules.

This is my output:

$ ncu -g
/usr/local/lib/node_modules/npm-check-updates/node_modules/npm/lib/ls.js:0
(function (exports, require, module, __filename, __dirname) { 

RangeError: Maximum call stack size exceeded
    at /usr/local/lib/node_modules/npm-check-updates/node_modules/npm/lib/ls.js:196:38
    at Array.forEach (native)
    at bfsify (/usr/local/lib/node_modules/npm-check-updates/node_modules/npm/lib/ls.js:196:21)
    at bfsify (/usr/local/lib/node_modules/npm-check-updates/node_modules/npm/lib/ls.js:216:10)
    at bfsify (/usr/local/lib/node_modules/npm-check-updates/node_modules/npm/lib/ls.js:216:10)
    at bfsify (/usr/local/lib/node_modules/npm-check-updates/node_modules/npm/lib/ls.js:216:10)
    at bfsify (/usr/local/lib/node_modules/npm-check-updates/node_modules/npm/lib/ls.js:216:10)
    at bfsify (/usr/local/lib/node_modules/npm-check-updates/node_modules/npm/lib/ls.js:216:10)
    at bfsify (/usr/local/lib/node_modules/npm-check-updates/node_modules/npm/lib/ls.js:216:10)
    at bfsify (/usr/local/lib/node_modules/npm-check-updates/node_modules/npm/lib/ls.js:216:10)
    at bfsify (/usr/local/lib/node_modules/npm-check-updates/node_modules/npm/lib/ls.js:216:10)
    at bfsify (/usr/local/lib/node_modules/npm-check-updates/node_modules/npm/lib/ls.js:216:10)
    at bfsify (/usr/local/lib/node_modules/npm-check-updates/node_modules/npm/lib/ls.js:216:10)
    at bfsify (/usr/local/lib/node_modules/npm-check-updates/node_modules/npm/lib/ls.js:216:10)
    at bfsify (/usr/local/lib/node_modules/npm-check-updates/node_modules/npm/lib/ls.js:216:10)
    at bfsify (/usr/local/lib/node_modules/npm-check-updates/node_modules/npm/lib/ls.js:216:10)

$ npm -g ls --depth=0
/usr/local/lib
├── bower@1.5.2
├── cordova@5.3.1
├── electron-packager@5.1.0
├── electron-prebuilt@0.32.1
├── generator-cordova-plugin@0.1.0
├── generator-electron@1.8.0
├── generator-material-app@0.1.4
├── goingnative@1.6.0
├── grunt-cli@0.1.13
├── gulp@3.9.0
├── ionic@1.6.4
├── ios-deploy@1.7.0
├── ios-sim@4.1.1
├── jscs@2.1.1
├── jshint@2.8.0
├── jspm@0.16.2
├── n@2.0.2
├── node-gyp@3.0.1
├── node-inspector@0.12.3
├── npm@2.14.2
├── npm-check-updates@2.2.2
├── plugman@1.0.2
└── yo@1.4.8
raineorshine commented 9 years ago

Thank you @lukaszkarbownik. I will investigate.

raineorshine commented 9 years ago

Sorry folks, still can't reproduce. There's not much I can do until either someone gives me a set of steps to reproduce, or someone debugs further on their end. If anyone who is experiencing the problem would be willing to take a few minutes to debug, it could potentially help many other users.

Since the loop goes infinite inside bfsify, which is called by ls, I would be curious what gets passed to lsFromTree that causes it to go infinite.

This could easily be an issue with the npm module itself.

raineorshine commented 9 years ago

I upgraded the internal npm module from v2 to v3. The ncu tests all still pass, and who knows, maybe there was a fix in npm that solved the infinite loop issue.

sidneys commented 9 years ago

It works for me! Takes an "awful lot" of time (i wonder where that call stack goes, but the exceptions seem to be handled somewhere), about 2 minutes. But it works.

Thank you for your work and this module! @metaraine