Standardizing out-of-memory and stack-depth-exceeded errors?

Garrett Smith dhtmlkitchen at
Wed Mar 23 18:21:49 PDT 2011

On 3/22/11, Joshua Bell <josh at> wrote:
> I was noodling with a (toy) compiler-to-JS for a (dead) language that
> supports error handlers for two boundary conditions - stack depth exceeded &
> out of memory - and noticed that the relevant behavior in JS is not standard
> across browsers. Has there been any discussion around standardization of
> errors thrown when limits of the script execution environment are hit?
> (Searching the archives didn't yield hits, but my search-fu may be weak
> today.)
> From briefly testing the boxes on my desk:
> stack depth:
> function a() { return a() + 1; } a();
> * IE9: Error, message: 'Out of stack space'
> * Firefox 4: InternalError, message: 'too much recursion'
javascript: alert(new InternalError("Got on tha inside, bitch!"));

Hrm. seems odd to expose the constructor publicly.

But FWIW, `new InternalError instanceof Error` is true.

> * Safari 5: RangeError, message 'Maximum call stack size exceeded'
> * Chrome 10: RangeError, message: 'Maximum call stack size exceeded', type:
> 'stack_overflow'
Agree with Brendan. Seems strange.

The infinite recursion could be detected and reported early. Where
does that happen? Does any engine report early for infinite recursion?

More information about the es-discuss mailing list