Sửa lỗi maximum nested error dialog depth reached

It means that somewhere in your code, you are calling a function which in turn calls another function and so forth, until you hit the call stack limit.

This is almost always because of a recursive function with a base case that isn't being met.

Viewing the stack

Consider this code...

[function a[] {
    a[];
}][];

Here is the stack after a handful of calls...

As you can see, the call stack grows until it hits a limit: the browser hardcoded stack size or memory exhaustion.

In order to fix it, ensure that your recursive function has a base case which is able to be met...

[function a[x] {
    // The following condition 
    // is the base case.
    if [ ! x] {
        return;
    }
    a[--x];
}][10];

answered May 23, 2011 at 10:05

16

In my case, I was sending input elements instead of their values:

$.post[ '',{ registerName: $['
# registerName'] } ]

Instead of:

$.post[ '',{ registerName: $['
# registerName'].val[] } ]

This froze my Chrome tab to a point it didn't even show me the 'Wait/Kill' dialog for when the page became unresponsive...

answered Aug 13, 2016 at 23:55

FK-FK-

1,4921 gold badge10 silver badges18 bronze badges

8

You can sometimes get this if you accidentally import/embed the same JavaScript file twice, worth checking in your resources tab of the inspector.

double-beep

5,15817 gold badges35 silver badges42 bronze badges

answered Apr 23, 2012 at 1:58

lucygeniklucygenik

1,6982 gold badges16 silver badges18 bronze badges

6

There is a recursive loop somewhere in your code [i.e. a function that eventually calls itself again and again until the stack is full].

Other browsers either have bigger stacks [so you get a timeout instead] or they swallow the error for some reason [maybe a badly placed try-catch].

Use the debugger to check the call stack when the error happens.

answered May 23, 2011 at 9:55

Aaron DigullaAaron Digulla

324k108 gold badges609 silver badges826 bronze badges

3

The problem with detecting stackoverflows is sometimes the stack trace will unwind and you won't be able to see what's actually going on.

I've found some of Chrome's newer debugging tools useful for this.

Hit the

$.post[ '',{ registerName: $['
# registerName'] } ]

9, make sure

$.post[ '',{ registerName: $['
# registerName'].val[] } ]

0 are enabled and you'll get something like this.

It's pretty obvious where the overflow is here! If you click on

$.post[ '',{ registerName: $['
# registerName'].val[] } ]

1 you'll be able to actually see the exact line number in the code.

You can also see timings which may or may not be helpful or a red herring.

Another useful trick if you can't actually find the problem is to put lots of

$.post[ '',{ registerName: $['
# registerName'].val[] } ]

2 statements where you think the problem is. The previous step above can help you with this.

In Chrome if you repeatedly output identical data it will display it like this showing where the problem is more clearly. In this instance the stack hit 7152 frames before it finally crashed:

answered Mar 7, 2017 at 13:03

Simon_WeaverSimon_Weaver

142k85 gold badges656 silver badges696 bronze badges

1

In my case, I was converting a large byte array into a string using the following:

String.fromCharCode.apply[null, new Uint16Array[bytes]]
$.post[ '',{ registerName: $['
# registerName'].val[] } ]

3 contained several million entries, which is too big to fit on the stack.

answered Mar 24, 2017 at 16:48

Nate GlennNate Glenn

6,5738 gold badges54 silver badges97 bronze badges

6

In my case, click event was propagating on child element. So, I had to put the following:

e.stopPropagation[]

on click event:

 $[document].on["click", ".remove-discount-button", function [e] {
           e.stopPropagation[];
           //some code
        }];
 $[document].on["click", ".current-code", function [] {
     $['.remove-discount-button'].trigger["click"];
 }];

Here is the html code:

 

Chủ Đề