gruntjs / grunt-lib-phantomjs

Grunt and PhantomJS, sitting in a tree.
http://gruntjs.com/
MIT License
93 stars 63 forks source link

phantomJSHandle undefined #70

Closed Krinkle closed 8 years ago

Krinkle commented 10 years ago
Testing http://localhost:9412/krinkle-mediawiki-core/index.php?title=Special:JavaScriptTest/qunit 
Warning: Cannot read property 'connected' of undefined Use --force to continue.
TypeError: Cannot read property 'connected' of undefined
    at exports.init.exports.spawn.kill (grunt-contrib-qunit/node_modules/grunt-lib-phantomjs/lib/phantomjs.js:59:28)
    at exports.init.exports.spawn.cleanup (grunt-contrib-qunit/node_modules/grunt-lib-phantomjs/lib/phantomjs.js:65:31)
    at node_modules/grunt-contrib-qunit/node_modules/grunt-lib-phantomjs/lib/phantomjs.js:174:7
    at util.spawn.callDone (grunt/node_modules/grunt-legacy-util/index.js:159:5)
    at Object.util.spawn (grunt/node_modules/grunt-legacy-util/index.js:178:7)
    at EventEmitter.exports.init.exports.spawn (grunt-contrib-qunit/node_modules/grunt-lib-phantomjs/lib/phantomjs.js:164:41)
    at module.exports (grunt-contrib-qunit/tasks/qunit.js:197:17)
    at async.forEachSeries.iterate (grunt/node_modules/async/lib/async.js:108:13)
    at Object.async.forEachSeries (grunt/node_modules/async/lib/async.js:124:9)
    at Object.module.exports (grunt-contrib-qunit/tasks/qunit.js:189:22)

Aborted due to warnings.

The kill() function assumes phantomJSHandle has been assigned. However when cleanup() is called in the immediate mode (like cleanup(null, true /* immediate */); from the grunt.util.spawn callback), it has not returned a value yet and as such is still undefined because it runs synchronously.

Krinkle commented 10 years ago

I ran into this when upgrading from grunt-contrib-qunit v0.4.0 to v0.5.2 (which upgrades grunt-lib-phantomjs from v0.5.0 to v0.6.0).

After manually patching this file in node_modules to check phantomJSHandle first, there is still a fatal error I can't do much with:

-         if (phantomJSHandle.pid){
+         if (phantomJSHandle && phantomJSHandle.pid){
Testing http://localhost:9412/krinkle-mediawiki-core/index.php?title=Special:JavaScriptTest/qunit 
PhantomJS threw an error:ERROR
>> TypeError: Cannot call method 'charAt' of null 0 [ 'TypeError: Cannot call method \'charAt\' of null' ]
>> In order for this task to work properly, PhantomJS must be installed locally
>> via NPM. If you're seeing this message, generally that means the NPM install
>> has failed. Please submit an issue providing as much detail as possible at:
>> https://github.com/gruntjs/grunt-lib-phantomjs/issues

Seems similar to #54 and #59.

FagnerMartinsBrack commented 9 years ago

I am also having this same symptom with v0.6.0 on Windows 7 when using grunt-contrib-qunit.

jsilland commented 9 years ago

I am seeing the same error on my Mac when using grunt-contrid-jasmine on a fresh npm install – this issue is referred in https://github.com/gruntjs/grunt-contrib-jasmine/issues/156

udayas8451 commented 9 years ago

When in run jasmine using grunt i see the following message. But this generates specRunner html file.Im trying to get the test execution summary on command line. And it fails because of following message.

Running "jasmine:unit" (jasmine) task Testing jasmine specs via PhantomJS

Warning: Cannot read property 'pid' of undefined Use --force to continue.

Aborted due to warnings.

Versions:

Phantomjsjs: 1.9.8 grunt-contrib-jasmine: ~0.9(what ever is the latest)

"grunt server --stack" logs:

TypeError: Cannot read property 'pid' of undefined at kill (C:\nodejs\sample\node_modules\grunt-contrib-jasmine\node_modules\grun t-lib-phantomjs\lib\phantomjs.js:59:28) at cleanup (C:\nodejs\sample\node_modules\grunt-contrib-jasmine\node_modules\g runt-lib-phantomjs\lib\phantomjs.js:65:31) at C:\nodejs\sample\node_modules\grunt-contrib-jasmine\node_modules\grunt-lib- phantomjs\lib\phantomjs.js:174:7 at callDone (C:\nodejs\sample\node_modules\grunt\node_modules\grunt-legacy-uti l\index.js:159:5) at Object.util.spawn (C:\nodejs\sample\node_modules\grunt\node_modules\grunt-l egacy-util\index.js:178:7) at EventEmitter.exports.spawn (C:\nodejs\sample\node_modules\grunt-contrib-jas mine\node_modules\grunt-lib-phantomjs\lib\phantomjs.js:164:41) at phantomRunner (C:\nodejs\sample\node_modules\grunt-contrib-jasmine\tasks\ja smine.js:140:15) at Object. (C:\nodejs\sample\node_modules\grunt-contrib-jasmine\tas ks\jasmine.js:108:5) at Object. (C:\nodejs\sample\node_modules\grunt\lib\grunt\task.js:2 64:15) at Object.thisTask.fn (C:\nodejs\sample\node_modules\grunt\lib\grunt\task.js:8 2:16)

Aborted due to warnings.

Please help me. What am I doing wrong here?

Thanks!

Arkni commented 8 years ago

From all the stack traces above, I conclude that there is a problem with the path of PhantomJS binary. The package phantomjs (aka phantomjs-prebuilt) is the one responsible for installing and providing us the path of PhantomJS binary. So this issue has nothing to do with this package even if the error message says otherwise.

A fresh install of this package should fix the issue. If persist, please report it to https://github.com/Medium/phantomjs.

Closing this for now, feel free to ask if you have followup questions.