Maximum call stack size exceeded error

后端 未结 30 2541
独厮守ぢ
独厮守ぢ 2020-11-21 23:51

I am using a Direct Web Remoting (DWR) JavaScript library file and am getting an error only in Safari (desktop and iPad)

It says

Maximum call

相关标签:
30条回答
  • 2020-11-22 00:17

    I am using React-Native 0.61.5 along with (npm 6.9.0 & node 10.16.1)

    While I am install any new libraries in Project I got an of

    (e.g. npm install @react-navigation/native --save)

    Maximum call stack size exceeded error

    for that, I try

    sudo npm cache clean --force

    (Note:- Below command usually take time 1 to 2 minutes depending on your npm cache size)

    0 讨论(0)
  • 2020-11-22 00:18

    For me as a beginner in TypeScript, it was a problem in the getter and the setter of _var1.

    class Point2{
        
        constructor(private _var1?: number, private y?: number){}
    
        set var1(num: number){
            this._var1 = num  // problem was here, it was this.var1 = num
        }
        get var1(){
            return this._var1 // this was return this.var1
        }
    }
    
    0 讨论(0)
  • 2020-11-22 00:19

    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...

    0 讨论(0)
  • 2020-11-22 00:21

    Nearly every answer here states that this can only be caused by an infinite loop. That's not true, you could otherwise over-run the stack through deeply nested calls (not to say that's efficient, but it's certainly in the realm of possible). If you have control of your JavaScript VM, you can adjust the stack size. For example:

    node --stack-size=2000

    See also: How can I increase the maximum call stack size in Node.js

    0 讨论(0)
  • 2020-11-22 00:21

    I know this thread is old, but i think it's worth mentioning the scenario i found this problem so it can help others.

    Suppose you have nested elements like this:

    <a href="#" id="profile-avatar-picker">
        <span class="fa fa-camera fa-2x"></span>
        <input id="avatar-file" name="avatar-file" type="file" style="display: none;" />
    </a>
    

    You cannot manipulate the child element events inside the event of its parent because it propagates to itself, making recursive calls until the exception is throwed.

    So this code will fail:

    $('#profile-avatar-picker').on('click', (e) => {
        e.preventDefault();
    
        $('#profilePictureFile').trigger("click");
    });
    

    You have two options to avoid this:

    • Move the child to the outside of the parent.
    • Apply stopPropagation function to the child element.
    0 讨论(0)
  • 2020-11-22 00:21

    in Angular, if you're using mat-select and have 400+ options, this error may occur https://github.com/angular/components/issues/12504

    you have to update @angular/material version

    0 讨论(0)
提交回复
热议问题