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

Stack Overflow Error when running a simple app in IE8 (started on Meteor 0.8.0) #2037

Closed
rainbough opened this issue Apr 9, 2014 · 4 comments
Closed

Comments

@rainbough
Copy link

@rainbough rainbough commented Apr 9, 2014

I just updated a live app to Meteor 0.8.0 about a week ago and shortly thereafter, we discovered that it no longer worked in internet explorer 8. It took a few days to figure out what was creating the error.

I have reproduced it here: https://github.com/rainbough/meteor0.8.0-ie8-bug

If you run this on a localhost it will work fine in IE8. The live site in IE8 shows a blank page and reports a stack-overflow error. The error occurs anytime a handlebars helper or template is enclosed in div tags like this:

<div>{{>hello}}</div>

<div>{{greeting}}</div>

It also comes up when the handlebars are in an attribute of an html tag:

<footer class={{pageClass}}></footer>

Body tags don't seem to have any impact on it.

I also discovered that the modernizr-meteor package changes the error to an "exception thrown and not caught" error, which created a lot of confusion until I removed the package.

BTW the error comes up on both heroku hosted sites and meteor hosted sites.

@glasser glasser added the Blaze label Apr 10, 2014
@avital
Copy link
Contributor

@avital avital commented Apr 14, 2014

Thanks for the clear report @rainbough!

I've verified this locally as well by running: meteor run --production, which minifies CSS and JavaScript. I haven't dug in yet but it's likely some surprise consequence of JS minification. I'd like to investigate more, and also figure out a way to test this going forward (we typically don't run our tests minified).

@avital
Copy link
Contributor

@avital avital commented Apr 14, 2014

We'll take a look at pull requests for this issue if someone gets to it before us.

@avital avital changed the title IE8 Meteor 0.8.0 infinite loop error Stack Overflow Error when running a simple app in IE8 (started on Meteor 0.8.0) May 15, 2014
@avital
Copy link
Contributor

@avital avital commented May 15, 2014

Here's a very simple reproduction: https://github.com/avital/meteor-user-bug-ie8 (thanks to @ManuelDeLeon)

@glasser
Copy link
Member

@glasser glasser commented May 21, 2014

As a fun hint on how to debug this stuff, apply this diff:

--- a/tools/bundler.js
+++ b/tools/bundler.js
@@ -709,7 +709,10 @@ _.extend(Target.prototype, {

     allJs = minifiers.UglifyJSMinify(allJs, {
       fromString: true,
-      compress: {drop_debugger: false}
+      compress: {drop_debugger: false},
+      output: { beautify: true,
+                indent_level: 2,
+                width: 80 }
     }).code;

     self.js = [new File({ data: new Buffer(allJs, 'utf8') })];

Then, it pretty-prints after mangling. Then the IE8 error should be on a recognizable line.

@glasser glasser closed this in 2db7490 May 21, 2014
glasser added a commit that referenced this issue May 22, 2014
The minifier changed the two uses of HTMLTag into two different symbols:

  var n = function r() {
    var t = this instanceof e.Tag ? this : new r(), n = 0, o = arguments.length && arguments[0];
    return o && "object" == typeof o && o.constructor === Object && (t.attrs = o, n++),
    n < arguments.length && (t.children = Array.prototype.slice.call(arguments, n)),
    t;
  };
  return n.prototype = new e.Tag(), n.prototype.constructor = n, n.prototype.tagName = t,
  n;

Then, IE8 apparently actually creates two separate objects for 'n' and
'r'; see #3 at http://kiro.me/blog/nfe_dilemma.html

So just because n.prototype is an e.Tag doesn't make r.prototype a e.Tag

This means that `new r() instanceof e.Tag` is false, and so the first
line of the function leads to infinite recursion.

I'm not sure if this is an uglify bug as well; dealing well with
multiple declarations of the same function may be out of spec.

Fixes #2037.
martijnwalraven pushed a commit that referenced this issue Feb 22, 2016
The minifier changed the two uses of HTMLTag into two different symbols:

  var n = function r() {
    var t = this instanceof e.Tag ? this : new r(), n = 0, o = arguments.length && arguments[0];
    return o && "object" == typeof o && o.constructor === Object && (t.attrs = o, n++),
    n < arguments.length && (t.children = Array.prototype.slice.call(arguments, n)),
    t;
  };
  return n.prototype = new e.Tag(), n.prototype.constructor = n, n.prototype.tagName = t,
  n;

Then, IE8 apparently actually creates two separate objects for 'n' and
'r'; see #3 at http://kiro.me/blog/nfe_dilemma.html

So just because n.prototype is an e.Tag doesn't make r.prototype a e.Tag

This means that `new r() instanceof e.Tag` is false, and so the first
line of the function leads to infinite recursion.

I'm not sure if this is an uglify bug as well; dealing well with
multiple declarations of the same function may be out of spec.

Fixes #2037.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants