-
Notifications
You must be signed in to change notification settings - Fork 144
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
Defend against run events firing in the wrong order. #111
Conversation
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. ---
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.
|
There was a problem hiding this 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.
Yes, that would work. 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. |
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. |
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? |
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. |
Yes, I've read that thread, too. Exactly nobody in that thread says with definity they aren't using karma-junit-reporter. |
That having been said - you're right. It probably is worthwhile to look at other module's code. I would prefer a real fix. |
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.