IE: "Stack overflow at line: 0" #86

Closed
matthewwithanm opened this Issue Nov 30, 2011 · 15 comments

Projects

None yet

10 participants

@matthewwithanm

I started getting this dreaded error while testing a page using Modernizr. Eventually I tracked it down to the MQ Polyfill option. To reproduce it, just add a lot of stylesheets (> 13) to a document. I haven't dug into the source, but it seems likely that the issue is explained by this article.

@scottjehl
Owner

Thanks! Sounds fixable. I'll take a look today.

@rico55

I ran into the same issue in IE7. I tracked it down to the recursive makeRequests call in the ajax callback. Wrapping the call in a setTimeout seems to clear it up for me.

@plainview

Hi, I saw this issue today and the fix suggested by rico55 worked a treat.

@matthewwithanm

I don't know that that's so much a fix as a workaround.

@hihain

The article matthewwithanm linked to describes the correct problem: If you have more than 12 css files in your HTML you get the error. Instead of a workaround I just combined my css files.

I think it is enough to mention this as a limitation in the readme.

@markweston

Hi,

I've been using Respond on a Magento site. I've split Magento's massive style.css file into many smaller files and respond seems to work absolutely fine with 25 css files in IE but fails when you add just one more. I can't be 100% on the number but I think that's correct.

Scott, do you have any idea if this is an IE recursion bug similar to that linked to above? The actual error fromthe console in IE dev tools is:

SCRIPT87: Invalid argument.
respond.src.js, line 268 character 12

Thanks,

Mark.

@joshrp

Also running into this issue with 21 CSS files, removing respond.js or compiling the files into a smaller number (for production) fixes the issue. no good in development though. found this which seems relevant:

http://cappuccino.org/discuss/2010/03/01/internet-explorer-global-variables-and-stack-overflows/

@tomasdev

Still happening :D boo.

@hellolindsay

Hi scottjehl, this is a pretty easy fix, think you can add it in?

Simply wrap line 102 in a setTimout function like this:

setTimeout(function() { makeRequests(); },0);

@scottjehl
Owner
@hellolindsay

Everyone's mind will rest easier if the script does the best it can for everyone without passing judgement.

Right now, when the script fails, it fails only for IE and it fails with a non-descriptive error message. That is frustrating and confusing for users. Yes, users with some skill may eventually stumble across this thread and read about how they should use fewer CSS files, but not before having struggled and lost a bunch of time. And while it is important to combine and compress CSS files in a production environment, it sometimes makes sense to be verbose in a test environment.

If you feel compelled to use this as a learning opportunity, don't let IE7 be the messenger. Instead, count the number of css files and add a descriptive popup that says something like "Whoa, that's a lot of CSS files! Read this article for more info." But even that, I would argue, undermines the elegance of this simple, wonderfully-useful, works-out-of-the-box script.

@Wilto
Collaborator

For what it’s worth, even IE7 itself fails (silently, I believe) above 31 stylesheets.

Given that the objective of this project was to provide a fast, lightweight polyfill for common media queries and given the performance overhead involved with parsing though 20+ stylesheets, I think the maintainer is within his rights to pass on accounting for this edge case. You might want to look into http://code.google.com/p/css3-mediaqueries-js, which is a more enterprise-class media query polyfill.

@hellolindsay

I have 15 stylesheets and the script fails. Upon reviewing the link below, I suspect the problem actually occurs with 13+ stylesheets.

http://cappuccino.org/discuss/2010/03/01/internet-explorer-global-variables-and-stack-overflows/

@scottjehl
Owner
@hellolindsay

PR sent! Take a look.

@scottjehl scottjehl closed this in c1736e7 Oct 29, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment