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

Defend against run events firing in the wrong order. #111

Conversation

randakar
Copy link
Contributor

@randakar randakar commented Dec 2, 2016

See #61 (comment) as for why.

What this mainly does is expose the real problem: onRunStart() firing out-of-order with the rest.
Looks like there are some races somewhere, but I'm not convinced the problem lies within karma-junit-test itself.

New error output:

Running "karma:unit" (karma) task
[D] Task source: C:\DATA\git\ymonitor-frontend\node_modules\grunt-karma\tasks\grunt-karma.js
Verifying property karma.unit exists in config...OK
File: [no files]
Options: background=false, client={}
02 12 2016 16:17:47.082:INFO [karma]: Karma v0.13.22 server started at http://localhost:8084/
02 12 2016 16:17:47.091:INFO [launcher]: Starting browser PhantomJS
02 12 2016 16:17:48.802:INFO [PhantomJS 2.1.1 (Windows 7 0.0.0)]: Connected on socket NHQQtIYrup2fNrbRAAAA with id 58745719
Warning: Task "karma:unit" failed. Use --force to continue.
Error: Task "karma:unit" failed.
at Task. (C:\DATA\git\ymonitor-frontend\node_modules\grunt\lib\util\task.js:205:15)
at null._onTimeout (C:\DATA\git\ymonitor-frontend\node_modules\grunt\lib\util\task.js:241:33)
at Timer.listOnTimeout (timers.js:92:15)

Aborted due to warnings.

See karma-runner#61 (comment) as for why.

What this mainly does is expose the real problem: onRunStart() firing out-of-order with the rest.
Looks like there are some races somewhere, but I'm not convinced the problem lies within karma-junit-test itself.

New error output:
---
Running "karma:unit" (karma) task
[D] Task source: C:\DATA\git\ymonitor-frontend\node_modules\grunt-karma\tasks\grunt-karma.js
Verifying property karma.unit exists in config...OK
File: [no files]
Options: background=false, client={}
02 12 2016 16:17:47.082:INFO [karma]: Karma v0.13.22 server started at http://localhost:8084/
02 12 2016 16:17:47.091:INFO [launcher]: Starting browser PhantomJS
02 12 2016 16:17:48.802:INFO [PhantomJS 2.1.1 (Windows 7 0.0.0)]: Connected on socket NHQQtIYrup2fNrbRAAAA with id 58745719
Warning: Task "karma:unit" failed. Use --force to continue.
Error: Task "karma:unit" failed.
    at Task.<anonymous> (C:\DATA\git\ymonitor-frontend\node_modules\grunt\lib\util\task.js:205:15)
    at null._onTimeout (C:\DATA\git\ymonitor-frontend\node_modules\grunt\lib\util\task.js:241:33)
    at Timer.listOnTimeout (timers.js:92:15)

Aborted due to warnings.
---
@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed, please reply here (e.g. I signed it!) and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
  • If you signed the CLA as a corporation, please let us know the company's name.

Copy link

@robinj robinj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another possible solution would be to initialise suites to be an empty array. That way you won't have to put guards all over the place. It only ever seems to be accessed as an array here.

@randakar
Copy link
Contributor Author

randakar commented Dec 2, 2016

Yes, that would work.
One other option would be to actually throw error messages if the events fire in the wrong order, telling the user that the real bug lies in the build tool calling these methods or in phantomjs / the browser. As arguably these things should not race against each other.

A third option might be to simply call the init function itself, or delay running until those events actually fired. Dirty, but possible, and maybe the fastest option to actually fix things.

@elicwhite
Copy link

It has been shown that this error occurs in many reporters. If this is a bug in the top level tool for calling events out of order, it should probably be fixed there.

@randakar
Copy link
Contributor Author

randakar commented Dec 2, 2016

Has it been? I haven't seen definite proof of that, to be honest. It wouldn't terribly surprise me but to say "it has been shown" is a stretch.

Besides, "Cannot read property '30193015' of null" sounds very specific for that 'var suites' we have in this module. Unless a lot of modules copy-paste the same bit of code. Which is possible I suppose. Not nice, but possible.

Either way, it doesn't hurt to at least initialize var suites to an empty array as robinj suggested. You move one line of code from "onRunStart()" to the variable declaration section, and it suddenly fails inside grunt (as described in the original post) rather than the karma-junit-reporter module.

Even better would be to at least loudly complain about it when this happens so that whomever wrote the buggy tool to begin with can fix their stuff, without having people scratching their heads over an obscure error for months. This has been reported in june, remember?

@elicwhite
Copy link

This issue has many people saying they are using different reporters all saying they have the same issue.

It would probably be worth checking some of the other reporters to see if they have the same logic and be able to figure out what the problem is upstream.

@randakar
Copy link
Contributor Author

randakar commented Dec 2, 2016

Yes, I've read that thread, too. Exactly nobody in that thread says with definity they aren't using karma-junit-reporter.

@randakar
Copy link
Contributor Author

randakar commented Dec 2, 2016

That having been said - you're right. It probably is worthwhile to look at other module's code. I would prefer a real fix.

@randakar randakar closed this Dec 5, 2016
@randakar randakar deleted the feature/issue-61-fix-null-suites-object-due-to-concurrency branch December 5, 2016 15:58
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 this pull request may close these issues.

4 participants