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

Bug [v1.1.0] : Cannot read property '88199994' of null #99

Closed
puneetar opened this issue Sep 17, 2016 · 6 comments
Closed

Bug [v1.1.0] : Cannot read property '88199994' of null #99

puneetar opened this issue Sep 17, 2016 · 6 comments

Comments

@puneetar
Copy link

Getting an exception:

Missing error handler on `socket`.
TypeError: Cannot read property '88199994' of null
  at onBrowserComplete (node_modules/karma-junit-reporter/index.js:120:23)
  at .<anonymous> (node_modules/karma/lib/events.js:13:22)
  at emitTwo (events.js:111:20)
  at emit (events.js:191:7)
  at onComplete (node_modules/karma/lib/browser.js:143:13)
  at Socket.<anonymous> (node_modules/karma/lib/events.js:13:22)
  at emitTwo (events.js:111:20)
  at Socket.emit (events.js:191:7)
  at Socket.onevent (node_modules/karma/node_modules/socket.io/lib/socket.js:335:8)
  at Socket.onpacket (node_modules/karma/node_modules/socket.io/lib/socket.js:295:12)
  at Client.ondecoded (node_modules/karma/node_modules/socket.io/lib/client.js:193:14)
  at Decoder.Emitter.emit (node_modules/component-emitter/index.js:134:20)
  at Decoder.add (node_modules/socket.io-parser/index.js:247:12)
  at Client.ondata (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 (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 (node_modules/karma/node_modules/engine.io/lib/transport.js:104:8)
  at WebSocket.Transport.onData (node_modules/karma/node_modules/engine.io/lib/transport.js:115:8)
  at WebSocket.onData (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 (node_modules/karma/node_modules/ws/lib/WebSocket.js:816:10)
  at node_modules/karma/node_modules/ws/lib/Receiver.js:477:18
  at Receiver.applyExtensions (node_modules/karma/node_modules/ws/lib/Receiver.js:364:5)
  at node_modules/karma/node_modules/ws/lib/Receiver.js:466:14
  at Receiver.flush (node_modules/karma/node_modules/ws/lib/Receiver.js:340:3)
  at Receiver.opcodes.1.finish (node_modules/karma/node_modules/ws/lib/Receiver.js:482:12)
  at Receiver.expectHandler (node_modules/karma/node_modules/ws/lib/Receiver.js:451:33)
  at Receiver.add (node_modules/karma/node_modules/ws/lib/Receiver.js:95:24)
  at Socket.realHandler (node_modules/karma/node_modules/ws/lib/WebSocket.js:800:20)
  at emitOne (events.js:96:13)
  at Socket.emit (events.js:188:7)
  at readableAddChunk (_stream_readable.js:177:18)
  at Socket.Readable.push (_stream_readable.js:135:10)
  at TCP.onread (net.js:542:20)

Expected : It should completed properly.

@Georgegriff
Copy link

Georgegriff commented Sep 26, 2016

I'm also seeing the same problem intermittently with v1.1.0 junit and v1.3.0 runner

@dpwatrous
Copy link

Same here - also with karma 1.3.0 and 1.1.0 of the reporter

@dpwatrous
Copy link

A bit more info - I have karma set up to watch for file changes. It seems I can reproduce this issue fairly reliably by changing a file rapidly and triggering test re-runs.

Specifically it seems as though triggering karma's watch while tests are running does the trick. Here's a bit more from my output - sanitized to protect the innocent.

[1] Chrome 53.0.2785 (Mac OS X 10.11.4): Executed 211 of 218 SUCCESS (0 secs / 2.526 secs)
29 09 2016 12:26:05.303:INFO [watcher]: Changed file "/foo/bar/my_test.js".
[1] 29 09 2016 12:26:05.657:INFO [karma]: Delaying execution, these browsers are not ready: Chrome 53.0.2785 (Mac OS X 10.11.4)
[1] Chrome 53.0.2785 (Mac OS X 10.11.4): Executed 211 of 218 SUCCESS (0 secs / 2.526 secs)
    Chrome 53.0.2785 (Mac OS X 10.11.4): Executed 218 of 218 SUCCESS (4.306 secs / 4.174 secs)
    Chrome 53.0.2785 (Mac OS X 10.11.4): Executed 0 of 218 SUCCESS (0 secs / 0 secs)
[1] Missing error handler on `socket`.
[1] TypeError: Cannot set property '66376449' of null
[1]     at initializeXmlForBrowser (/foo/bar/node_modules/karma-junit-reporter/index.js:48:36)
[1]     at JUnitReporter.onBrowserStart (/foo/bar/node_modules/karma-junit-reporter/index.js:116:5)
[1]     at Server.<anonymous> (/foo/bar/node_modules/karma/lib/events.js:13:22)
[1]     at emitTwo (events.js:111:20)
[1]     at Server.emit (events.js:191:7)
[1]     at Browser.onStart (/foo/bar/node_modules/karma/lib/browser.js:126:13)
[1]     at Socket.<anonymous> (/foo/bar/node_modules/karma/lib/events.js:13:22)
[1]     at emitOne (events.js:101:20)
[1]     at Socket.emit (events.js:188:7)
[1]     at Socket.onevent (/foo/bar/node_modules/socket.io/lib/socket.js:335:8)
[1]     at Socket.onpacket (/foo/bar/node_modules/socket.io/lib/socket.js:295:12)
[1]     at Client.ondecoded (/foo/bar/node_modules/socket.io/lib/client.js:193:14)
[1]     at Decoder.Emitter.emit (/foo/bar/node_modules/component-emitter/index.js:134:20)
[1]     at Decoder.add (/foo/bar/node_modules/socket.io-parser/index.js:247:12)
[1]     at Client.ondata (/foo/bar/node_modules/socket.io/lib/client.js:175:18)
[1]     at emitOne (events.js:96:13)
[1]     at Socket.emit (events.js:188:7)
[1] 29 09 2016 12:26:08.980:INFO [watcher]: Changed file "/foo/bar/my_test.js".
[1] 29 09 2016 12:26:09.270:INFO [karma]: Delaying execution, these browsers are not ready: Chrome 53.0.2785 (Mac OS X 10.11.4)
    Chrome 53.0.2785 (Mac OS X 10.11.4) ERROR
[1]   Disconnectedundefined

@dpwatrous
Copy link

Looking at the stack traces a bit more closely, this could be two separate issues (onBrowserStart vs onBrowserComplete), but they're awfully similar.

@dpwatrous
Copy link

dpwatrous commented Sep 29, 2016

I don't have time to look into this further at the moment, and I'm pretty new to karma, but my guess is that in index.js onRunComplete runs and sets the suites object to null, then onBrowserStart runs, tries to use the suites object and explodes 💥

thatmarvin added a commit to thatmarvin/karma-junit-reporter that referenced this issue Nov 30, 2016
When a watcher triggers Karma to re-run a test, onRunComplete() from
the first test run happens after onRunStart() from the second test run.
This results in `suites` incorrectly clobbered to null.

Nulling it out is unnecessary as long as onRunStart() initializes
`suites`.

Fixes karma-runner#99.
@thatmarvin
Copy link
Contributor

@dpwatrous 's assessment is spot-on. In a regular, uninterrupted test run, the sequence of events looks like this:

onRunStart
onBrowserStart
onBrowserComplete
onRunComplete

However, if a test run is interrupted by a new test run (usually triggered by a file change), the sequence looks like this:

onRunStart A
onBrowserStart A

// New test run B gets triggered here while test run A is still running

onRunStart B
onRunComplete A // suites = null
onBrowserStart B // suites[browser.id] throws
onBrowserComplete B
onRunComplete B

If you want to reproduce this, you'd want to try it on on longer test runs when there's a larger window of time to trigger a fs change to trigger a new test run.

Karma should probably not have triggered onRunComplete() because the test run wasn't actually completed, but I doubt that's gonna change on Karma's end. So PR #110 fixes this simply by removing suites = null in onRunComplete(), as I don't think it's doing anything meaningful in terms of cleaning up/garbage collection that it presumably tries to do.

dignifiedquire pushed a commit that referenced this issue Dec 1, 2016
When a watcher triggers Karma to re-run a test, onRunComplete() from
the first test run happens after onRunStart() from the second test run.
This results in `suites` incorrectly clobbered to null.

Nulling it out is unnecessary as long as onRunStart() initializes
`suites`.

Fixes #99.
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

4 participants