Unplanned
Last Updated: 05 Apr 2021 15:23 by Jason
Jason
Created on: 05 Apr 2021 14:17
Category: Ajax
Type: Feature Request
1
RadAjaxManager can cause a browser stack overflow when RequestQueueSize is used and

Attached is a reproduction project page with a <script> containing a workaround.

Reproduction steps:

1) Run the page

2) Hover quickly between the two colored squares (do this up to 15-20 seconds)

3) Observe the error in the browser's console:

Uncaught RangeError: Maximum call stack size exceeded
    at Function.Array.addRange 
    at Telerik.Web.UI.RadAjaxManager._executePendingRequest 
    at Object._endRequest 
    at Array.<anonymous> 
    at Sys.WebForms.PageRequestManager._endPostBack 
    at Sys.WebForms.PageRequestManager._scriptsLoadComplete 
    at Sys.WebForms.PageRequestManager.<anonymous>   
    at Sys._ScriptLoader._loadScriptsInternal 

 

Workaround: Place/load this script somewhere after the ScriptManager of the page

<script>
    Telerik.Web.UI.RadAjaxControl.prototype._executePendingRequest = function () {
        var pendingRequest = Array.dequeue(this._requestQueue);

        var eventTarget = pendingRequest[0];
        var eventArgument = pendingRequest[1];

        if (this._requestQueue.length > 0 && this.__id != "") {
            var currentAjaxControl = $find(this.__id);
            if (currentAjaxControl) {
                Array.addRange(currentAjaxControl._requestQueue, this._requestQueue);
                // optional, uncomment if issue persists
                //if (currentAjaxControl._requestQueue.length > currentAjaxControl._requestQueueSize) {
                //    // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice#parameters 
                //    // using negative index for start to get the last N elements
                //    currentAjaxControl._requestQueue =
                //        currentAjaxControl._requestQueue.slice(-currentAjaxControl._requestQueueSize)
                //}
            }
        }

        var requestManager = Sys.WebForms.PageRequestManager.getInstance();
        requestManager._doPostBack(eventTarget, eventArgument);
    }
</script>

Attached Files:
1 comment
Jason
Posted on: 05 Apr 2021 15:23

To whom it may concern:

Given the option, I'd prefer to see the second suggestion (from this ticket) in the release product as opposed to the proposed workaround, as it seems to be a clearer implementation and also less work for the browser to just avoid the addRange in the first place, as applicable.

i.e.

...

if (currentAjaxControl && currentAjaxControl != this) {
                Array.addRange(currentAjaxControl._requestQueue, this._requestQueue);

...

 

Best Regards,

Jason Borne