macbre / phantomas

Headless Chromium-based web performance metrics collector and monitoring tool
https://www.npmjs.com/package/phantomas
BSD 2-Clause "Simplified" License
2.26k stars 141 forks source link

Multiple Runs Results in: TypeError: Bad argument #598

Open sshaw opened 8 years ago

sshaw commented 8 years ago

Just tried to execute the multiple runs example and got a TypeError:

~ >phantomas https://github.com/macbre/phantomas --verbose --runs 5

/usr/local/lib/node_modules/phantomas/node_modules/phantomjs-prebuilt/lib/location.js:1
(function (exports, require, module, __filename, __dirname) {
                                                              ^
TypeError: Bad argument
    at ChildProcess.spawn (child_process.js:933:24)
    at exports.spawn (child_process.js:733:9)
    at engines.run (/usr/local/lib/node_modules/phantomas/lib/engines.js:128:10)
    at phantomas (/usr/local/lib/node_modules/phantomas/lib/index.js:66:16)
    at task (/usr/local/lib/node_modules/phantomas/bin/phantomas.js:145:14)
    at /usr/local/lib/node_modules/phantomas/node_modules/async/lib/async.js:718:13
    at iterate (/usr/local/lib/node_modules/phantomas/node_modules/async/lib/async.js:262:13)
    at async.forEachOfSeries.async.eachOfSeries (/usr/local/lib/node_modules/phantomas/node_modules/async/lib/async.js:281:9)
    at _parallel (/usr/local/lib/node_modules/phantomas/node_modules/async/lib/async.js:717:9)
    at Object.async.series (/usr/local/lib/node_modules/phantomas/node_modules/async/lib/async.js:739:9)
sshaw commented 8 years ago

So between npm installing this and the above run I installed some local dependencies for another project and gulp globally. This is what caused the above error. Once I reinstall phantomas, it works. This is under node 0.10.28 :grin:...

macbre commented 8 years ago

I installed some local dependencies

What were these dependencies?

sshaw commented 8 years ago

What were these dependencies?

   "backbone": "^1.1.2",
    "gulp": "^3.9.0",
    "gulp-compressor": "^0.1.0",
    "gulp-concat": "^2.6.0",
    "gulp-htmlmin": "^1.3.0",
    "gulp-imagemin": "^2.2.1",
    "gulp-load-plugins": "^0.10.0",
    "gulp-minify": "0.0.5",
    "gulp-minify-css": "^1.2.3",
    "gulp-requirejs-optimize": "^0.3.0",
    "gulp-uglify": "^1.5.1",
    "gulp-uncss": "^1.0.4",
    "handlebars": "^4.0.5",
    "jquery": "^2.1.1",
    "panini": "^1.1.1",
    "rimraf": "^2.4.4",
    "run-sequence": "^1.1.5",
    "yargs": "^3.31.0",
    "zurb-foundation-npm": "0.0.1"
kidbai commented 8 years ago

I got the same problem and my node version is 5.11.0 . But it is not working when I reinstall phantomas.

internal/child_process.js:278
  var err = this._handle.spawn(options);
                         ^

TypeError: Bad argument
    at TypeError (native)
    at ChildProcess.spawn (internal/child_process.js:278:26)
    at exports.spawn (child_process.js:367:9)
    at engines.run (/Users/Youngbye/.nvm/versions/v5.11.0/lib/node_modules/phantomas/lib/engines.js:127:10)
    at phantomas (/Users/Youngbye/.nvm/versions/v5.11.0/lib/node_modules/phantomas/lib/index.js:66:16)
    at task (/Users/Youngbye/.nvm/versions/v5.11.0/lib/node_modules/phantomas/bin/phantomas.js:145:14)
    at /Users/Youngbye/.nvm/versions/v5.11.0/lib/node_modules/phantomas/node_modules/async/dist/async.js:4819:13
    at replenish (/Users/Youngbye/.nvm/versions/v5.11.0/lib/node_modules/phantomas/node_modules/async/dist/async.js:838:21)
    at /Users/Youngbye/.nvm/versions/v5.11.0/lib/node_modules/phantomas/node_modules/async/dist/async.js:848:15
    at eachOfLimit (/Users/Youngbye/.nvm/versions/v5.11.0/lib/node_modules/phantomas/node_modules/async/dist/async.js:3622:26)
xiuhonglee commented 8 years ago

I reinstalled phantomjs & phantomas , but it is not working.

  nternal/child_process.js:278
  var err = this._handle.spawn(options);
                         ^

TypeError: Bad argument
    at TypeError (native)
    at ChildProcess.spawn (internal/child_process.js:278:26)
    at exports.spawn (child_process.js:383:9)
    at engines.run (/usr/local/lib/node_modules/phantomas/lib/engines.js:127:10)
    at phantomas (/usr/local/lib/node_modules/phantomas/lib/index.js:66:16)
    at task (/usr/local/lib/node_modules/phantomas/bin/phantomas.js:145:14)
    at /usr/local/lib/node_modules/phantomas/node_modules/async/dist/async.js:5285:13
    at replenish (/usr/local/lib/node_modules/phantomas/node_modules/async/dist/async.js:871:21)
    at /usr/local/lib/node_modules/phantomas/node_modules/async/dist/async.js:881:15
    at eachOfLimit (/usr/local/lib/node_modules/phantomas/node_modules/async/dist/async.js:3952:26)
macbre commented 8 years ago

@xiuhonglee, are there any debug log messages emitted before the error shows up? Please provide npm and nodejs version. Are you installing from npm or cloning git repo?

sgc-fireball commented 8 years ago

same error here.

node -v # v6.2.1 npm -v # 3.9.3

macbre commented 8 years ago

Guys, thanks for the reports. Please run phantomas in really verbose mode and provide the full output here:

DEBUG=* phantomas https://github.com/macbre/phantomas --verbose --runs 5
lizicuenca commented 8 years ago

** Added at - 20160829 I got my error fixed. I was installing other tools so I just listed out all my steps. One thing i learn is testing phantomJS in isolation. Run it phantomJS from your command line and run some code from phantomJS site to make sure it works alone.

# reinstall phantomjs
sudo npm install -g phantomjs
sudo npm -g install phantomjs-prebuilt
sudo npm -g install phantomas

# rebuild lwip (for my other tools) 
rm .node-gyp (from my home directory) 
sudo apt-get install -y build-essential

# remove node_modules from YellowLabTools 
rm -r ./YellowLabTools/node_modules

# reinstall everything
cd YellowLabTools
npm install

After above, my server is up. i am now running into error 252. I suspect that error is from phantomjs and decided to test it in isolation. run phantomjs only and got an error like below: /usr/lib/node_modules/uncss/node_modules/phridge/node_modules/phantomjs/lib/phantom/bin/phantomjs: error while loading shared libraries: libfontconfig.so.1: cannot open shared object file: No such file or directory

resolved above issue using:

sudo apt-get install libfontconfig **

I am run into same error. I am stuck right now, any help would be appreciated. I tried to reinstall phantomas and phantomjs, however neither work.
I am installing YellowLabTool for performance measure in an aws instance. I hope this could help you reproduce the error. I created this instance today and the only thing i installed are listed below: Server : ubuntu node -v : v6.4.0 npm -v : 3.10.3

AWS image standard ubuntu version: ubuntu/images/hvm-ssd/ubuntu-trusty-14.04-amd64-server-20160714 (ami-d732f0b7) Here is my installation steps:

curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
 sudo apt-get install nodejs
 sudo apt-get install git
sudo apt-get install libjpeg-dev
git clone https://github.com/gmetais/YellowLabTools.git
cd YellowLabTools/
npm install
//npm install log -- refer to below (log_1_npm_install)
//======= above installation finish without error

node bin/server.js
//node bin/server.js return some errors related lwip-- refer to below (Log_2_nodejs_bin_server.js)

====================== rebuild lwip
cd node_modules/lwip/
npm rebuild

node bin/server.js
==== server is up with follow log
:~/YellowLabTools$ node bin/server.js
Listening on port 8383
Sending response without waiting.
Test failed for URL: http://www.google.com
TypeError: Bad argument
=== however every time i hit the server, I got above error. 

=== I decided to run the script directly now I got more debug info: 
ubuntu@ip:~/YellowLabTools$ node bin/cli.js http://www.google.com
internal/child_process.js:278
  var err = this._handle.spawn(options);
                         ^

TypeError: Bad argument
    at TypeError (native)
    at ChildProcess.spawn (internal/child_process.js:278:26)
    at exports.spawn (child_process.js:380:9)
    at engines.run (/home/ubuntu/YellowLabTools/node_modules/phantomas/lib/engines.js:127:10)
    at phantomas (/home/ubuntu/YellowLabTools/node_modules/phantomas/lib/index.js:66:16)
    at /home/ubuntu/YellowLabTools/lib/tools/phantomas/phantomasWrapper.js:125:27
    at /home/ubuntu/YellowLabTools/node_modules/async/lib/async.js:651:21
    at /home/ubuntu/YellowLabTools/node_modules/async/lib/async.js:718:13
    at iterate (/home/ubuntu/YellowLabTools/node_modules/async/lib/async.js:262:13)
    at async.forEachOfSeries.async.eachOfSeries (/home/ubuntu/YellowLabTools/node_modules/async/lib/async.js:281:9)

============ log_1_npm_install =============== ubuntu@ip:~/YellowLabTools$ npm install npm WARN deprecated cross-spawn-async@2.2.4: cross-spawn no longer requires a bu ild toolchain, use it instead! npm WARN deprecated lodash-node@2.4.1: This package has been discontinued in fav or of lodash@^4.0.0. npm WARN deprecated tough-cookie@2.2.2: ReDoS vulnerability parsing Set-Cookie h ttps://nodesecurity.io/advisories/130 npm WARN deprecated minimatch@0.2.14: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue npm WARN deprecated minimatch@0.3.0: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue npm WARN deprecated graceful-fs@1.2.3: graceful-fs v3.0.0 and before will fail o n node releases >= v7.0. Please update to graceful-fs@^4.0.0 as soon as possible . Use 'npm ls graceful-fs' to find it in the tree. npm WARN deprecated lodash@1.0.2: lodash@<3.0.0 is no longer maintained. Upgrade to lodash@^4.0.0. npm WARN deprecated CSSselect@0.7.0: the module is now available as 'css-select' npm WARN deprecated CSSwhat@0.4.7: the module is now available as 'css-what' npm WARN deprecated to-iso-string@0.0.2: to-iso-string has been deprecated, use @segment/to-iso-string instead. npm WARN deprecated jade@0.26.3: Jade has been renamed to pug, please install th e latest version of pug instead of jade npm WARN prefer global svgicons2svgfont@1.1.0 should be installed with -g npm WARN prefer global analyze-css@0.12.1 should be installed with -g npm WARN prefer global jshint@2.9.3 should be installed with -g npm WARN prefer global node-gyp@3.4.0 should be installed with -g npm WARN prefer global ttf2woff2@2.0.3 should be installed with -g

thread-sleep@1.0.4 install /home/ubuntu/YellowLabTools/node_modules/thread-sle ep node-pre-gyp install --fallback-to-build

===================== Log_1 - finish ===================== ===================== Log_2_nodejs_bin_server.js ===================== ubuntu@ip:~/YellowLabTools$ node bin/server.js /home/ubuntu/YellowLabTools/node_modules/bindings/bindings.js:91 throw err ^

Error: Could not locate the bindings file. Tried: → /home/ubuntu/YellowLabTools/node_modules/lwip/build/lwip_image.node → /home/ubuntu/YellowLabTools/node_modules/lwip/build/Debug/lwip_image.node → /home/ubuntu/YellowLabTools/node_modules/lwip/build/Release/lwip_image.node → /home/ubuntu/YellowLabTools/node_modules/lwip/out/Debug/lwip_image.node → /home/ubuntu/YellowLabTools/node_modules/lwip/Debug/lwip_image.node → /home/ubuntu/YellowLabTools/node_modules/lwip/out/Release/lwip_image.node → /home/ubuntu/YellowLabTools/node_modules/lwip/Release/lwip_image.node → /home/ubuntu/YellowLabTools/node_modules/lwip/build/default/lwip_image.node → /home/ubuntu/YellowLabTools/node_modules/lwip/compiled/6.4.0/linux/x64/lwip_i mage.node at bindings (/home/ubuntu/YellowLabTools/node_modules/bindings/bindings.js:8 8:9) at /home/ubuntu/YellowLabTools/node_modules/lwip/lib/Image.js:3:41 at Object. (/home/ubuntu/YellowLabTools/node_modules/lwip/lib/Ima ge.js:16:3) at Module._compile (module.js:556:32) at Object.Module._extensions..js (module.js:565:10) at Module.load (module.js:473:32) at tryModuleLoad (module.js:432:12) at Function.Module._load (module.js:424:3) at Module.require (module.js:483:17) at require (internal/module.js:20:19) ===================== Log_2 END =====================