Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Frequent disconnecting while debugging in single runs #2532

Closed
dead-claudia opened this issue Jan 9, 2017 · 7 comments
Closed

Frequent disconnecting while debugging in single runs #2532

dead-claudia opened this issue Jan 9, 2017 · 7 comments

Comments

@dead-claudia
Copy link

dead-claudia commented Jan 9, 2017

Expected behaviour

No disconnection while idling in the debugger

Actual behaviour

Wait in the debugger for more than 2 seconds, and the connection is dropped

Environment Details

  • Karma version (output of karma --version): 1.3.0
  • Relevant part of your karma.config.js file
// karma.conf.js
module.exports = function (config) {
    config.set({
        browsers: ["PhantomJSDebug"],
        frameworks: ["mocha"],
        customLaunchers: {
            PhantomJSDebug: {
                base: "PhantomJS",
                debug: true,
            },
        },
        files: ["test.js"],
        browserNoActivityTimeout: 1000000000,
    })
}

// test.js
describe("debug", function () {
    it("works", function () {
        debugger
    })
})

Steps to reproduce the behaviour

  1. Install the relevant packages (npm i karma karma-mocha karma-phantomjs-launcher mocha)
  2. Run karma start --single-run
  3. Open the inspector page
  4. Idle there for a couple minutes or so.

It then proceeds to disconnect, ignoring the astronomically high browserNoActivityTimeout. I suspect part of it is because the main loop is blocked, ensuring the websocket doesn't get any data. Sending the test data from a web worker should alleviate the problem, since it's no longer blocked by the debugger on the main thread. (Long running tests would also benefit from this.)

On the other hand, it's odd that the timeout is even being ignored at all. It's extremely difficult to debug failing PhantomJS tests when this is going on (and it's very specific to that platform).

@dead-claudia
Copy link
Author

Here's the output of the above, but with --log-level debug:

09 01 2017 16:47:42.749:DEBUG [config]: Loading config /home/isiah/dev-projects/js/tmp/tmp/karma.conf.js
09 01 2017 16:47:42.775:DEBUG [config]: autoWatch set to false, because of singleRun
09 01 2017 16:47:42.779:DEBUG [plugin]: Loading karma-* from /home/isiah/dev-projects/js/tmp/tmp/node_modules
09 01 2017 16:47:42.783:DEBUG [plugin]: Loading plugin /home/isiah/dev-projects/js/tmp/tmp/node_modules/karma-mocha.
09 01 2017 16:47:42.791:DEBUG [plugin]: Loading plugin /home/isiah/dev-projects/js/tmp/tmp/node_modules/karma-phantomjs-launcher.
09 01 2017 16:47:42.919:DEBUG [plugin]: Loading inlined plugin (defining launcher:PhantomJSDebug).
09 01 2017 16:47:42.953:DEBUG [web-server]: Instantiating middleware
09 01 2017 16:47:43.103:INFO [karma]: Karma v1.3.0 server started at http://localhost:9876/
09 01 2017 16:47:43.104:INFO [launcher]: Launching browser PhantomJSDebug with unlimited concurrency
09 01 2017 16:47:43.122:INFO [launcher]: Starting browser PhantomJS
09 01 2017 16:47:43.124:DEBUG [temp-dir]: Creating temp dir at /tmp/karma-45794312
09 01 2017 16:47:43.153:DEBUG [launcher]: /home/isiah/dev-projects/js/tmp/tmp/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs --remote-debugger-port=9000 --remote-debugger-autorun=yes /tmp/karma-45794312/capture.js
09 01 2017 16:47:43.179:INFO [phantomjs.launcher]: ACTION REQUIRED:
09 01 2017 16:47:43.180:INFO [phantomjs.launcher]: 
09 01 2017 16:47:43.180:INFO [phantomjs.launcher]:   Launch browser at
09 01 2017 16:47:43.181:INFO [phantomjs.launcher]:   http://localhost:9000/webkit/inspector/inspector.html?page=2
09 01 2017 16:47:43.181:INFO [phantomjs.launcher]: 
09 01 2017 16:47:43.181:INFO [phantomjs.launcher]: Waiting 15 seconds ...
09 01 2017 16:47:43.411:DEBUG [phantomjs.launcher]: Launch the debugger page at http://localhost:9000/webkit/inspector/inspector.html?page=2
Waiting 15 seconds for debugger page to launch...

09 01 2017 16:47:58.604:DEBUG [phantomjs.launcher]: Launching page http://localhost:9876/?id=45794312...

09 01 2017 16:47:58.640:DEBUG [web-server]: serving: /home/isiah/dev-projects/js/tmp/tmp/node_modules/karma/static/client.html
09 01 2017 16:47:58.685:DEBUG [web-server]: serving: /home/isiah/dev-projects/js/tmp/tmp/node_modules/karma/static/karma.js
09 01 2017 16:47:58.888:DEBUG [karma]: A browser has connected on socket /#rXWT0YOccqIkSjOBAAAA
09 01 2017 16:47:58.941:DEBUG [web-server]: upgrade /socket.io/?EIO=3&transport=websocket&sid=rXWT0YOccqIkSjOBAAAA
09 01 2017 16:47:59.033:INFO [PhantomJS 2.1.1 (Linux 0.0.0)]: Connected on socket /#rXWT0YOccqIkSjOBAAAA with id 45794312
09 01 2017 16:47:59.035:DEBUG [launcher]: PhantomJS (id 45794312) captured in 15.93 secs
09 01 2017 16:47:59.059:DEBUG [phantomjs.launcher]: 

09 01 2017 16:47:59.064:DEBUG [middleware:karma]: custom files null null
09 01 2017 16:47:59.065:DEBUG [middleware:karma]: Serving static request /context.html
09 01 2017 16:47:59.070:DEBUG [web-server]: serving: /home/isiah/dev-projects/js/tmp/tmp/node_modules/karma/static/context.html
09 01 2017 16:47:59.087:DEBUG [middleware:source-files]: Requesting /base/node_modules/mocha/mocha.js?0491afff0b566ea45cd04c9164a355dba705689e /
09 01 2017 16:47:59.088:DEBUG [middleware:source-files]: Fetching /home/isiah/dev-projects/js/tmp/tmp/node_modules/mocha/mocha.js
09 01 2017 16:47:59.091:DEBUG [web-server]: serving (cached): /home/isiah/dev-projects/js/tmp/tmp/node_modules/mocha/mocha.js
09 01 2017 16:47:59.103:DEBUG [middleware:source-files]: Requesting /base/node_modules/karma-mocha/lib/adapter.js?e8826109cf50b958ee4bd667517729ffdd4de363 /
09 01 2017 16:47:59.104:DEBUG [middleware:source-files]: Fetching /home/isiah/dev-projects/js/tmp/tmp/node_modules/karma-mocha/lib/adapter.js
09 01 2017 16:47:59.107:DEBUG [middleware:source-files]: Requesting /base/test.js?b9347b9d7feb3456bf8dfe34e7e7578ad5c59d3c /
09 01 2017 16:47:59.108:DEBUG [middleware:source-files]: Fetching /home/isiah/dev-projects/js/tmp/tmp/test.js
09 01 2017 16:47:59.109:DEBUG [web-server]: serving (cached): /home/isiah/dev-projects/js/tmp/tmp/node_modules/karma-mocha/lib/adapter.js
09 01 2017 16:47:59.111:DEBUG [web-server]: serving (cached): /home/isiah/dev-projects/js/tmp/tmp/test.js
09 01 2017 16:47:59.114:DEBUG [web-server]: serving: /home/isiah/dev-projects/js/tmp/tmp/node_modules/karma/static/context.js
PhantomJS 2.1.1 (Linux 0.0.0): Executed 0 of 1 SUCCESS (0 secs / 0 secs)
09 01 2017 16:49:24.313:DEBUG [PhantomJS 2.1.1 (Linux 0.0.0)]: Disconnected during run, waiting 2000ms for reconnecting.
09 01 2017 16:49:26.316:WARN [PhantomJS 2.1.1 (Linux 0.0.0)]: Disconnected (1 tPhantomJS 2.1.1 (Linux 0.0.0) ERROR
  Disconnectedundefined
PhantomJS 2.1.1 (Linux 0.0.0): Executed 0 of 1 DISCONNECTED (1 min 27.053 secs PhantomJS 2.1.1 (Linux 0.0.0): Executed 0 of 1 DISCONNECTED (1 min 27.053 secs / 0 secs)
09 01 2017 16:49:26.325:DEBUG [karma]: Run complete, exiting.
09 01 2017 16:49:26.327:DEBUG [launcher]: Disconnecting all browsers
09 01 2017 16:49:26.361:DEBUG [launcher]: Process PhantomJS exited with code 0
09 01 2017 16:49:26.362:DEBUG [temp-dir]: Cleaning temp dir /tmp/karma-45794312
09 01 2017 16:49:26.373:DEBUG [launcher]: Finished all browsers

@wesleycho
Copy link
Member

If it helps, if you set autoWatch to true and singleRun to false, you could click the debug button in the browser that opens up (cannot use PhantomJS in this case I believe), and set a breakpoint to debug the test.

Not sure if it would help you work around this case though with PhantomJS.

@dead-claudia
Copy link
Author

@wesleycho I appreciate the tip (didn't know --single-run would cause similar issues in GUI browsers), but for headless browsers like PhantomJS, yeah, not so much... 😦

@vivganes
Copy link
Contributor

@wesleycho @isiahmeadows Is this same as issue mentioned in #2447 ?

@vivganes
Copy link
Contributor

@dignifiedquire I believe this will be fixed by adding a big numerical value for processKillTimeout property. I have created a PR #2541 to update the docs.

But, in order to be used by @isiahmeadows, we might need to release a version.

@isiahmeadows Is it possible for you to check directly from master? Do you require a release?

@wesleycho
Copy link
Member

@vivganes you can always specify to consume a specific commit with npm. Karma doesn't have a build process, so it wouldn't depend on anything special being done.

@dead-claudia
Copy link
Author

dead-claudia commented Jan 19, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants