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

Fatal error: Cannot read property %browser.id% of null #20

Closed
syavorsky opened this issue Apr 27, 2014 · 12 comments
Closed

Fatal error: Cannot read property %browser.id% of null #20

syavorsky opened this issue Apr 27, 2014 · 12 comments

Comments

@syavorsky
Copy link

Error happens if browser failed on start. Simplest case is when test case contained a Syntax Error. Here is the example, run grunt to se the issue.

It is rather Karma problem, because onBrowserComplete is triggered twice and suites is null'ed by the second call. Here is some debugging output:

--> onRunStart
INFO [karma]: Karma v0.12.12 server started at http://localhost:9876/
INFO [launcher]: Starting browser Chrome
INFO [Chrome 34.0.1847 (Mac OS X 10.9.2)]: Connected on socket zY0n_4LMncgG3V6ETzU9 with id 87250253
Chrome 34.0.1847 (Mac OS X 10.9.2) ERROR
  Uncaught SyntaxError: Unexpected end of input
  at /Users/siavorskyi/projects/CD/karma-junit-reporter-failure/test/syntax-error.spec.js:4

Chrome 34.0.1847 (Mac OS X 10.9.2): Executed 0 of 0 SUCCESS (0 secs / 0 secs)
--> onBrowserStart 87250253
--> initliazeXmlForBrowser
Chrome 34.0.1847 (Mac OS X 10.9.2): Executed 0 of 0 ERROR (0.002 secs / 0 secs)
--> onBrowserComplete 87250253 // suites is Object
--> onRunComplete
Chrome 34.0.1847 (Mac OS X 10.9.2): Executed 0 of 0 ERROR (0.004 secs / 0 secs)
--> onBrowserComplete 87250253 // suites is null
--> onRunComplete
@dcheslow
Copy link

I am having a similar (related?) problem. The browser Safari gets disconnected and then Karma tries to use the browser again, producing the same symptom. Note that the property name (last line) and the browser id for Safari (first line) are the same:

INFO [Safari 7.0.5 (Mac OS X 10.9.4)]: Connected on socket zTI9jtNWzoZKrulU5Q6n with id 10854247
INFO [Chrome 35.0.1916 (Mac OS X 10.9.4)]: Connected on socket 6Yt7AmX6_1c3OOi05Q6o with id 7862841
INFO [Safari 7.0.5 (Mac OS X 10.9.4)]: Connected on socket xCdLA-A3zbzrI_mO5Q6m with id 40855390
INFO [Firefox 30.0.0 (Mac OS X 10.9)]: Connected on socket voBi3f_NPvl77owT5Q6p with id 68411812
................................................................................
................................................................................
.....................................................................
Safari 7.0.5 (Mac OS X 10.9.4): Executed 135 of 135�[32m SUCCESS�[39m (0.7 secs / 0.64 secs)
................................................................................
................................................................................
Chrome 35.0.1916 (Mac OS X 10.9.4): Executed 135 of 135�[32m SUCCESS�[39m (1.288 secs / 1.204 secs)
................
Firefox 30.0.0 (Mac OS X 10.9): Executed 135 of 135�[32m SUCCESS�[39m (1.37 secs / 1.271 secs)
�[32mTOTAL: 405 SUCCESS�[39m
WARN [Safari 7.0.5 (Mac OS X 10.9.4)]: Disconnected (1 times)
Safari 7.0.5 (Mac OS X 10.9.4): Executed 0 of 135�[31m DISCONNECTED�[39m (3.28 secs / 0 secs)
Fatal error: Cannot read property '10854247' of null

My current work-around sucks quite a lot: remove Safari, build, re-add Safari, build again.
I have tried various fiddling with timeouts and disconnect tolerance.... no joy.
It seems to me that the base problem is that Safari is getting disconnected, not that the failed browser is a fatal error.
Any/all suggestions are appreciated.

@hyzhak
Copy link

hyzhak commented Sep 25, 2014

I have same problem with Phantom JS and [email protected] but after 100 tests are passed. It fails occasionally. So after some reloads, all tests are passed without any problem, but in general it is weird experience:

TypeError: Cannot read property '73488940' of null
    at JUnitReporter.specSuccess.specSkipped.specFailure (.....\node_modules\karma-junit-reporter\index.js:89:22)
    at BaseReporter.onSpecComplete (.....\node_modules\karma\lib\reporters\base.js:83:12)
    at bindMethod (.....\node_modules\karma\lib\events.js:15:22)
    at EventEmitter.emit (events.js:117:20)
    at Browser.onResult (.....\node_modules\karma\lib\browser.js:213:13)
    at Socket.bindMethod (.....\node_modules\karma\lib\events.js:15:22)
    at Socket.EventEmitter.emit [as $emit] (events.js:117:20)
    at SocketNamespace.handlePacket (.....\node_modules\karma\node_modules\socket.io\lib\namespace.js:335:22)
    at Manager.onClientMessage (.....\node_modules\karma\node_modules\socket.io\lib\manager.js:518:38)
    at WebSocket.Transport.onMessage (.....\node_modules\karma\node_modules\socket.io\lib\transport.js:369:20)

How to fix this bug?

@j0tunn
Copy link

j0tunn commented Mar 18, 2015

Looks like it relates to karma itself: karma-runner/karma#1248
And it was fixed

@wookets
Copy link

wookets commented May 8, 2015

Are we sure this was fixed?

I'm seeing this in Karma 0.12.31.

Fatal error: Cannot read property '21770261' of null


Actually my issue appears to be an async test not been done properly...

@rhencke
Copy link

rhencke commented Jan 12, 2016

I believe I've distilled this error (or one very, very much like it) down to a minimal reproduction - this consistently errors with TypeError: Cannot read property 'somenumber' of null

To reproduce:

git clone https://gist.github.com/rhencke/919d12c168e2300da133 bug20
cd bug20
npm install
npm test

@rhencke
Copy link

rhencke commented Jan 12, 2016

I think the underlying bug for this is actually karma-runner/karma#1292

What is happening is that onRunComplete is called, and suites is set to null at https://github.com/karma-runner/karma-junit-reporter/blob/master/index.js#L120. Then, later, a specSuccess/specSkipped/specFailure arrives (https://github.com/karma-runner/karma-junit-reporter/blob/v0.2.2/index.js#L89 from @hyzhak 's stack trace, but now https://github.com/karma-runner/karma-junit-reporter/blob/v0.3.8/index.js#L125 in the current release). It attempts to reference suites, but suites has been set to null, and the TypeError occurs.

@tomwetjens
Copy link

Still experiencing this issue with karma 0.13.22 and karma-junit-reporter 0.4.0. Can you please merge the workaround by @alexeibs https://github.com/Megaputer/karma-junit-reporter/commit/d14b9bffe0d3d658b8a99e2854b3e8070e50c11f until karma-runner/karma#1292 is solved?

@muhammad-ammar
Copy link

Still getting this issue with karma 0.13.22 and karma-junit-reporter 0.4.1. Any way to fix this issue?

@rhencke
Copy link

rhencke commented Mar 24, 2016

@muhammad-ammar We 'fixed' this locally in our case but it took code changes to karma-junit-reporter. (I say 'fixed' because we did not address the underlying bug - we just made it work despite that).

I don't have the code changes handy but our workaround looked very much like the one in @alexeibs's fork here: https://github.com/Megaputer/karma-junit-reporter/commit/d14b9bffe0d3d658b8a99e2854b3e8070e50c11f and here: https://github.com/Megaputer/karma-junit-reporter/commit/9138c062c343262bccaa71571aca30d6e11d579b). You may want to try that for now.

@muhammad-ammar
Copy link

👍 @rhencke Thanks a lot for your reply and commit links.

@stramel
Copy link

stramel commented Jul 22, 2016

karma-runner/karma#1292

@wesleycho
Copy link
Member

This error should be fixed in the karma-junit-reporter 1.2.0 release.

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

Successfully merging a pull request may close this issue.

10 participants