simplecov-ruby/simplecov-html

Javascript error in version '0.12.0', some pages cannot be open

Closed this issue · 15 comments

Javascript error in version '0.12.0'.

Uncaught Error: Syntax error, unrecognized expression: a.src_link[href=#4eb942230860ef99bbe56de21801de7c3054304f]
    at Function.w.error (<anonymous>:1:28701)
    at w.tokenize (<anonymous>:2:1891)
    at w.select (<anonymous>:2:2156)
    at Function.w [as find] (<anonymous>:1:17673)
    at Te.fn.init.find (<anonymous>:2:4445)
    at new Te.fn.init (<anonymous>:2:5054)
    at Te (<anonymous>:1:14075)
    at HTMLDocument.<anonymous> (<anonymous>:7:5122)
    at t (<anonymous>:2:9165)
    at a (<anonymous>:2:9471)

I ran unit test with simplecov-html 0.11.0, no error occurred.

But when I upgrade simplecov-html into version 0.12.0, when I open some of the code coverage items(including nearly all the controllers and more than half of the helpers, but the coverage percentage value is correct), this error is thrown.

My ruby version is 2.6.5, rails version is 6.0.2.1, simplecov version is 0.18.2.

👋

Hi @HansBug thanks for opening an issue!

Could you please include code that throws the error? It seems that the code highlighter is erroring out at some point. Without the code to reproduce this error, it's nigh impossible for us to fix :)

Cheers,
Tobi

Emmm, I'm really sorry, the code on our side is not convenient to disclose directly for some reasons (large scale, and it is temporarily impossible to determine what this error is related to).

I will try the different versions (0.11.0 and 0.12.0) of the code to reproduce this error. May be wait for some moments.

@HansBug yeah, I can see how that's a problem. Would be mightily helpful though. It seems the last release also introduced unicode character errors (see #91 ) - so maybe it's related?

Thanks for your report and your help! 💚

Emm, maybe it's different. In that case the page can still be opened properly, only the non-ascii characters cannot be displayed. But in my case, the page that shows which lines are covered and which lines not cannot be displayed (the javascript error above occurs at this time) when I click the .rb file's path.

yeah I just thought it might be related aka through the unicode error weird characters are inserted which makes the parser crash 🤷‍♂️

I'm just saying, as some files work I think it has to be related to something odd happening in the code.

Highlighter was one of the few packages I did not upgrade though so it might also be that in some path it tries to access some jQuery function that isn't there anymore. Maybe updating it would solve it, but I'm honestly unsure what highlighter package it is 🤷‍♂️

Same issue on my side. I have the issue on a really simple stupid file:

class Brand < ActiveRecord::Base
end

Steps to recreate using a public repo:

% ruby --version
ruby 2.5.7p206 (2019-10-01 revision 67816) [x86_64-darwin19]
% git clone https://github.com/thoughtbot/factory_bot.git
% cd factory_bot
% bundle install
% bundle update simplecov simplecov-html
% bundle exec rspec
# open ./coverage/index.html
# Click "Next" in the pagination
# Try to open any file on that page

I tested this in Chrome and Firefox using both "file:///" urls and loaded through a webserver and anything outside the first 10 results won't load.

Thanks a bunch this will be helpful in fixing/debugging this :)

Yeah the more I see it now it's that just everything on the second page doesn't load to which #93 is a kinda great solution 👼

@HansBug can you confirm that this only happens on "not the first page" ? The error I get is different and the file doesn't open at all. Just wanna find out if this is "the same" or another error.

The error referenced in this issue

Error: Syntax error, unrecognized expression: a.src_link[href=#10233c3a374374beb92db32fe83f29e616c6d742]

happens in the following scenarios.

  • Going to page 2+ and opening a file causes the error.
  • Changing the show results to 25+ and opening a file causes the error.
  • Viewing one of the working files then refreshing the page causes the error.

@HansBug can you confirm that this only happens on "not the first page" ? The error I get is different and the file doesn't open at all. Just wanna find out if this is "the same" or another error.

Yes, exactly! I tried this case just now, all the links in first page can be displayed correctly, all the other pages can not.

Great thank you! I'll just disable pagination pagination then 👼 #93

edit: expect a release hopefully today

Fixed via #96 or at least to the best of my understanding.