karma-runner / karma-runner/karma

Missing error handler on `socket` when I get "Delaying execution, these browsers are not ready: Chrome" from previous test

Open
#2,526 3 comments 2 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
12k
Forks
1.7k
PR merge metrics
No merged PRs in 30d

Description

### Expected behaviour
I expect Karma not to crash when it runs the test again after displaying "Delaying execution, these browsers are not ready: Chrome" from the previous test.

### Actual behaviour
This happens when I make some changes and then save my file. Before karma finishes running, if I do another save after a change, it will first interrupt the test with `04 01 2017 15:00:37.775:INFO [karma]: Delaying execution, these browsers are not ready: Chrome 55.0.2883 (Mac OS X 10.11.6)`.

Then, it will finish the rest of the expectations (they are all green), and then display

```
=========================================================================================================================

START:

Finished in 0 secs / 0 secs
```

before running the test again, because of that second save that I did. Then it will run through all my tests again (all green), and then give this error with the missing error handler on socket:

```
Missing error handler on `socket`.
TypeError: Cannot read property 'set' of null
at KarmaRemapIstanbul.onBrowserComplete (/Users/kamok/code/election/election-mobile/node_modules/karma-remap-istanbul/index.js:28:16)
at Server. (/Users/kamok/code/election/election-mobile/node_modules/karma/lib/events.js:13:22)
at emitTwo (events.js:111:20)
at Server.emit (events.js:191:7)
at Browser.onComplete (/Users/kamok/code/election/election-mobile/node_modules/karma/lib/browser.js:143:13)
at Socket. (/Users/kamok/code/election/election-mobile/node_modules/karma/lib/events.js:13:22)
at emitTwo (events.js:111:20)
at Socket.emit (events.js:191:7)
at Socket.onevent (/Users/kamok/code/election/election-mobile/node_modules/karma/node_modules/socket.io/lib/socket.js:335:8)
at Socket.onpacket (/Users/kamok/code/election/election-mobile/node_modules/karma/node_modules/socket.io/lib/socket.js:295:12)
at Client.ondecoded (/Users/kamok/code/election/election-mobile/node_modules/karma/node_modules/socket.io/lib/client.js:193:14)
at Decoder.Emitter.emit (/Users/kamok/code/election/election-mobile/node_modules/component-emitter/index.js:134:20)
at Decoder.add (/Users/kamok/code/election/election-mobile/node_modules/socket.io-parser/index.js:247:12)
at Client.ondata (/Users/kamok/code/election/election-mobile/node_modules/karma/node_modules/socket.io/lib/client.js:175:18)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at Socket.onPacket (/Users/kamok/code/election/election-mobile/node_modules/karma/node_modules/engine.io/lib/socket.js:101:14)
at emitOne (events.js:96:13)
at WebSocket.emit (events.js:188:7)
at WebSocket.Transport.onPacket (/Users/kamok/code/election/election-mobile/node_modules/karma/node_modules/engine.io/lib/transport.js:104:8)
at WebSocket.Transport.onData (/Users/kamok/code/election/election-mobile/node_modules/karma/node_modules/engine.io/lib/transport.js:115:8)
at WebSocket.onData (/Users/kamok/code/election/election-mobile/node_modules/karma/node_modules/engine.io/lib/transports/websocket.js:76:30)
at emitTwo (events.js:106:13)
at WebSocket.emit (events.js:191:7)
at Receiver.ontext (/Users/kamok/code/election/election-mobile/node_modules/karma/node_modules/ws/lib/WebSocket.js:816:10)
at /Users/kamok/code/election/election-mobile/node_modules/karma/node_modules/ws/lib/Receiver.js:477:18
at /Users/kamok/code/election/election-mobile/node_modules/karma/node_modules/ws/lib/Receiver.js:361:7
at /Users/kamok/code/election/election-mobile/node_modules/karma/node_modules/ws/lib/PerMessageDeflate.js:247:5
at afterWrite (_stream_writable.js:387:3)
at onwrite (_stream_writable.js:378:7)
at WritableState.onwrite (_stream_writable.js:89:5)
at afterTransform (_stream_transform.js:79:3)
at TransformState.afterTransform (_stream_transform.js:54:12)
at Zlib.callback (zlib.js:639:5)
04 01 2017 15:00:48.724:WARN [Chrome 55.0.2883 (Mac OS X 10.11.6)]: Disconnected (1 times)
Chrome 55.0.2883 (Mac OS X 10.11.6) ERROR
Disconnectedundefined
Chrome 55.0.2883 (Mac OS X 10.11.6) ERROR
Disconnectedundefined
```

### Environment Details

- Karma version (output of `karma --version`):
Karma version: 1.3.0
- Relevant part of your `karma.config.js` file
```
basePath: '',
frameworks: [
'jasmine',
'angular-cli',
'jasmine-matchers' // https://github.com/JamieMason/karma-jasmine-matchers
],
plugins: [
require('karma-phantomjs-launcher'),
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-remap-istanbul'),
require('karma-mocha-reporter'),
require('angular-cli/plugins/karma'),
require('karma-jasmine-matchers') // https://github.com/JamieMason/karma-jasmine-matchers
],
files: [ // http://karma-runner.github.io/1.0/config/files.html
{ pattern: './src/test.ts', watched: false },
{ pattern: './www/assets/images/*.jpg', watched: false, included: false, served: true},
{ pattern: './www/json/*.json', watched: false, included: false, served: true}
],
preprocessors: {
'./src/test.ts': ['angular-cli']
},
remapIstanbulReporter: {
reports: {
html: 'coverage',
lcovonly: './coverage/coverage.lcov'
}
},
proxies: {
'/assets/': '/base/www/assets/',
'/json/': '/base/www/json/',
},
angularCli: {
config: './angular-cli.json',
environment: 'dev'
},
reporters: [
'mocha', 'karma-remap-istanbul'
],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'], // 'PhantomJS' or 'Chrome'
singleRun: false,
mime: { 'text/x-typescript': ['ts', 'tsx'] }
```
### Steps to reproduce the behaviour

See above. This is only is Chrome. On PhantomJS it works fine. Basically Karma shutsdown if I save again before the first test is finished running.

Contributor guide

Open the contributing guide

Research direction

Reproduce the Chrome failure by saving again while the previous Karma run is still finishing. Start with karma-remap-istanbul/index.js at onBrowserComplete and trace the Karma flow through karma/lib/events.js and karma/lib/browser.js. Done means repeated saves no longer cause the missing socket error, crash, or Chrome disconnection.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.