{"action":"created","issue":{"url":"https://api.github.com/repos/karma-runner/karma/issues/1035","repository_url":"https://api.github.com/repos/karma-runner/karma","labels_url":"https://api.github.com/repos/karma-runner/karma/issues/1035/labels{/name}","comments_url":"https://api.github.com/repos/karma-runner/karma/issues/1035/comments","events_url":"https://api.github.com/repos/karma-runner/karma/issues/1035/events","html_url":"https://github.com/karma-runner/karma/issues/1035","id":31747457,"node_id":"MDU6SXNzdWUzMTc0NzQ1Nw==","number":1035,"title":"Karma doesn't exit properly when using public api with the finish callback","user":{"login":"pkozlowski-opensource","id":973550,"node_id":"MDQ6VXNlcjk3MzU1MA==","avatar_url":"https://avatars3.githubusercontent.com/u/973550?v=4","gravatar_id":"","url":"https://api.github.com/users/pkozlowski-opensource","html_url":"https://github.com/pkozlowski-opensource","followers_url":"https://api.github.com/users/pkozlowski-opensource/followers","following_url":"https://api.github.com/users/pkozlowski-opensource/following{/other_user}","gists_url":"https://api.github.com/users/pkozlowski-opensource/gists{/gist_id}","starred_url":"https://api.github.com/users/pkozlowski-opensource/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pkozlowski-opensource/subscriptions","organizations_url":"https://api.github.com/users/pkozlowski-opensource/orgs","repos_url":"https://api.github.com/users/pkozlowski-opensource/repos","events_url":"https://api.github.com/users/pkozlowski-opensource/events{/privacy}","received_events_url":"https://api.github.com/users/pkozlowski-opensource/received_events","type":"User","site_admin":false},"labels":[{"id":17117422,"node_id":"MDU6TGFiZWwxNzExNzQyMg==","url":"https://api.github.com/repos/karma-runner/karma/labels/needs:%20investigation","name":"needs: investigation","color":"fbca04","default":false},{"id":1994755,"node_id":"MDU6TGFiZWwxOTk0NzU1","url":"https://api.github.com/repos/karma-runner/karma/labels/type:%20bug","name":"type: bug","color":"e10c02","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":16,"created_at":"2014-04-17T17:49:52Z","updated_at":"2018-10-24T13:58:03Z","closed_at":"2014-04-25T06:34:55Z","author_association":"MEMBER","body":"Using Karma's server public API with a done callback makes the whole node process \"stuck\" - there are probably some event listeners that prevent node process from exiting properly. A simple reproduce scenario:\n\n``` javascript\nvar karma = require('karma').server;\n\nkarma.start({\n  //transports: ['websocket', 'xhr-polling', 'jsonp-polling'],\n  browsers: ['Chrome'],\n  frameworks: ['jasmine'],\n  files: [\n    'src/**/*.js',\n    'test/**/*.spec.js'\n  ],\n  singleRun: true\n}, function(karmaExitCode) {\n  console.log('Karma exited with ', karmaExitCode);\n  console.log('but the process will never exit...');\n});\n```\n\nInterestingly, removing the flash from the list of transports make the Karma exit after a while (~20s after test are finished on my machine).\n\nThere is a small repo with the reproduce scenario here:\nhttps://github.com/karma-runner/gulp-karma/blob/exit_pb/exitTest.js\nI will be digging into the topic but any help from someone more knowledgeable about Karma internals would be highly appreciated.  \n"},"comment":{"url":"https://api.github.com/repos/karma-runner/karma/issues/comments/432668118","html_url":"https://github.com/karma-runner/karma/issues/1035#issuecomment-432668118","issue_url":"https://api.github.com/repos/karma-runner/karma/issues/1035","id":432668118,"node_id":"MDEyOklzc3VlQ29tbWVudDQzMjY2ODExOA==","user":{"login":"Ivaylo-Lafchiev","id":10599277,"node_id":"MDQ6VXNlcjEwNTk5Mjc3","avatar_url":"https://avatars2.githubusercontent.com/u/10599277?v=4","gravatar_id":"","url":"https://api.github.com/users/Ivaylo-Lafchiev","html_url":"https://github.com/Ivaylo-Lafchiev","followers_url":"https://api.github.com/users/Ivaylo-Lafchiev/followers","following_url":"https://api.github.com/users/Ivaylo-Lafchiev/following{/other_user}","gists_url":"https://api.github.com/users/Ivaylo-Lafchiev/gists{/gist_id}","starred_url":"https://api.github.com/users/Ivaylo-Lafchiev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Ivaylo-Lafchiev/subscriptions","organizations_url":"https://api.github.com/users/Ivaylo-Lafchiev/orgs","repos_url":"https://api.github.com/users/Ivaylo-Lafchiev/repos","events_url":"https://api.github.com/users/Ivaylo-Lafchiev/events{/privacy}","received_events_url":"https://api.github.com/users/Ivaylo-Lafchiev/received_events","type":"User","site_admin":false},"created_at":"2018-10-24T13:58:03Z","updated_at":"2018-10-24T13:58:03Z","author_association":"NONE","body":"I've run into the same issue, tested on karma@1.7.1 and karma@latest in my project's gulp chain. Seems there are socket.io handlers (detected using why-is-node-running) that aren't resolved for a good 30-40 seconds after karma has finished executing the tests. The above solutions provided by @npetruzzelli  are of no help as they terminate the node process and the following tasks are not executed. \r\n\r\nI was hoping #3149 would help but it seems that despite Karma exiting gracefully after the test run it seems socket.io is still holding the process hostage. I'm going to try what was suggested by @jnwu but I'm not sure this is the best solution to the problem. "}}
{"actor":{"display_login":"Ivaylo-Lafchiev"}}