mathiasbynens / he

A robust HTML entity encoder/decoder written in JavaScript.
https://mths.be/he
MIT License
3.45k stars 254 forks source link

Internet Explorer 11 + Edge 12-13-14 JavaScript parsing issues #53

Closed gnutix closed 7 years ago

gnutix commented 7 years ago

Hello,

I'm using this library in production and get reports of JavaScript errors (in TrackJS.com) from IE & Edge browsers like:

And when I check the error file / line, it's sometimes in he.js, like here :

fireshot capture 7 - track_js error_ expected identifier _ - https___my trackjs com_details_bb01

And sometimes it's in other parts of the code (like in YUI library)... seems completely random, by the way :

fireshot capture 10 - track_js error_ expected _ - https___my trackjs com_details_09c

fireshot capture 11 - track_js error_ expected _ - https___my trackjs com_details_f53

fireshot capture 12 - track_js error_ illegal character_ - https___my trackjs com_details_1a7

The only idea I have would be that IE shits on himself when loading the very long JSON defined in he.js. Or maybe the fact that there's very long strings processed in regex ?

Here's the exact version of he.js I'm using in my project : he.js.zip I've modified it a bit, trying to cut the very long lines into shorter lines. Which didn't fixed it.

Have you ever had any issue of this kind ?

Thanks a lot for your help. gnutix

mathiasbynens commented 7 years ago

Have you ever had any issue of this kind?

40 sounds similar. It sounds like this issue only occurs randomly / sometimes — is that correct?

Could you provide a reduced test case so I can easily verify the issue?

gnutix commented 7 years ago

Concerning #40, on my application there is only YUI code that is minified. All other vendors (incl he.js) and the application code is not.

I've never encountered it myself, as I'm on Linux and don't have IE11/Edge easily available and never (yet) went through the trouble of settting up VMs. According to the high number of visitors on the application and the low number of errors reported, and their random nature (in the error itself and the file/line it points to), I fear that it will be Mission Impossible to have a truly reproducible test case...

In the meantime, I've replaced he.js by a simple regex (even though I know the drawbacks), just to isolate if it's the source of the issue or not (might be YUI, or minified YUI, or even another piece of code...). Once I'll know for sure that it's caused by he.js, maybe I'll find the time to dig more into it (VMs and such)

gnutix commented 7 years ago

I've had the error again without he.js in the project! ... I've added it again. Now let's see if YUI minified is the cause. I'll keep you posted just in case someone else, someday, has the same issue.

mathiasbynens commented 7 years ago

Much appreciated!

gnutix commented 7 years ago

I had two error reports even with non-minified JS... :( Guess I'll still have to find a solution. If you're curious to follow : http://stackoverflow.com/questions/43044844/ie11-edge-12-13-14-random-javascript-parsing-errors-caused-by-very-long-obje