DataTables 2.0 Excel Export Uncaught RangeError: Maximum call stack size exceeded

DataTables 2.0 Excel Export Uncaught RangeError: Maximum call stack size exceeded

rnovoarnovoa Posts: 4Questions: 1Answers: 0

Hello,
After upgrading from 1.13.1 to 2.0.x I found that the export to Excel button function has stopped working on larger datasets, where we have multiple columns of data.

Here is the error we are receiving:

Uncaught RangeError: Maximum call stack size exceeded
at new U (datatables.min.js:30:45597)
at U.iterator (datatables.min.js:30:46841)
at U.<anonymous> (datatables.min.js:30:65184)
at U.render (datatables.min.js:30:47734)
at u (datatables.min.js:40:25642)
at U.<anonymous> (datatables.min.js:40:23735)
at Function.exportData (datatables.min.js:30:47734)
at U.action (datatables.min.js:60:20955)
at r (datatables.min.js:40:6771)
at datatables.min.js:40:6949

As a sample, I have created fiddler example that does not work with the existing but would work with the old.
https://jsfiddle.net/rnovoa/szdrnake/4/

I've also run debugger configuration: asibeq

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,489Questions: 1Answers: 10,470 Site admin

    Thank you for the test case. I don't have an immediate fix I'm afraid. It works in Firefox, but Chrome isn't happy. I'll look into it and reply back here.

    Allan

  • rnovoarnovoa Posts: 4Questions: 1Answers: 0

    Thanks for looking into this

    rnovoa

  • AnthonyCAnthonyC Posts: 1Questions: 0Answers: 0

    Hey was there a solution to this issue? I am encountering a similar problem with export excel in version 2.0.8 and 2.0.7. I have about 7k records and am facing a maximum stack call error on chrome and safari. Oddly it works on Firefox. Is there a way to fix this?

  • allanallan Posts: 63,489Questions: 1Answers: 10,470 Site admin

    Firefox appears to have a higher allowance for this, or perhaps it have a different method for checking for infinite loops. I haven't had a chance to sit down and focus on trying to resolve this yet I'm afraid. It is something I'm aware of though and will be trying to make some time to look into it as soon as I can.

    Allan

  • eliasmazureliasmazur Posts: 5Questions: 2Answers: 0

    Hello. Just checking if there is a solution for this issue. I'm trying to upgrade to 2.0 and still get this error. Unfortunately users rely heavily on Excel generation and it's a controlled environment so only Chrome and Edge are allowed, so no Firefox.

    Thanks for looking into it.

    Elias

  • allanallan Posts: 63,489Questions: 1Answers: 10,470 Site admin

    I haven't yet dug into this I'm afraid. It is on my agenda, it just hasn't been reached yet.

    Allan

  • eliasmazureliasmazur Posts: 5Questions: 2Answers: 0

    Hi Allan.

    Thanks for the quick reply. Do you have a ballpark timeframe when will this be looked into? I have a large production application with large amounts of data and as I mentioned users require Excel generation.

    Thanks again.
    Elias

  • allanallan Posts: 63,489Questions: 1Answers: 10,470 Site admin

    I haven't had anyone with a paid support package ask about this yet, which is one to the main reasons I haven't been able to prioritise it over other things. I would hope to look at on the next week or two though.

    Allan

  • professormuddprofessormudd Posts: 4Questions: 1Answers: 0

    I think I have a solution for this....

    in the _Api constructor function:

    // Initial data
    if ( data ) {
       this.push.apply(this, data);
    }
    

    It is possible that .apply is exceeding the amount of arguments with large data sets or large amounts of columns (both in my case).

    // Initial data
    if ( data ) {
       // Instead of using apply, manually push elements to avoid stack overflow
       for (var i = 0; i < data.length; i++) {
          this.push(data[i]);
       }
    }
    

    Making this change to my local copy of the datatables.js file seemed to correct the issue.

  • allanallan Posts: 63,489Questions: 1Answers: 10,470 Site admin

    Interesting - thanks for posting this. That gives me another avenue to look into!

    Allan

  • allanallan Posts: 63,489Questions: 1Answers: 10,470 Site admin

    With @professormudd's suggestion I think this is fixed. Thank you for your insight!

    I've committed the change and it is now in the nightly. It seems to work nicely in Chrome with a 50000x6 table for me (whereas I was getting the same error as reported before the change). However, I'd welcome someone else to try it out from the nightly and confirm the fix before I do the release.

    Allan

  • vt167098vt167098 Posts: 3Questions: 0Answers: 0

    I tried a table with more than 6 columns(actually 7 columns) and 20,000 rows of table, but the same problem still occurred. feedback to you. Thanks.

  • allanallan Posts: 63,489Questions: 1Answers: 10,470 Site admin

    Hi - thanks for testing the change. Can you give me a link to a page showing the issue please?

    I've just tried it here and it appears to work okay for a 20'000 x 7 table.

    Possibly your page is using an old cached version of the nightly? Try adding a query string to it like in my example or link above.

    Allan

  • vt167098vt167098 Posts: 3Questions: 0Answers: 0
    edited August 27

    Hi, Allan:

    Your example code import css file & js lib

        <link href="https://nightly.datatables.net/css/dataTables.dataTables.css" rel="stylesheet" type="text/css" />
        <script src="https://nightly.datatables.net/js/dataTables.js?523492"></script>
    
        <link href="https://cdn.datatables.net/v/dt/jszip-3.10.1/b-3.1.1/b-html5-3.1.1/datatables.min.css" rel="stylesheet">
     
    <script src="https://cdn.datatables.net/v/dt/jszip-3.10.1/b-3.1.1/b-html5-3.1.1/datatables.min.js"></script>
    
    

    I used file is different from yours.

        <link href="https://nightly.datatables.net/css/dataTables.dataTables.css" rel="stylesheet" type="text/css" />
        <link href="https://cdn.datatables.net/v/dt/jq-3.7.0/jszip-3.10.1/dt-2.1.4/b-3.1.1/b-html5-3.1.1/fc-5.0.1/datatables.min.css" rel="stylesheet">
        <script src="https://nightly.datatables.net/js/dataTables.js?523492"></script>
        <script src="https://cdn.datatables.net/v/dt/jq-3.7.0/jszip-3.10.1/dt-2.1.4/b-3.1.1/b-html5-3.1.1/fc-5.0.1/datatables.min.js"></script>
    
    

    I changed it to the same file as yours. Now it's work very fine.

    Thanks your help.

    Vincent

  • datatablesIsNicedatatablesIsNice Posts: 1Questions: 0Answers: 0

    Hi Allan,

    we had the same issue in one of our implementations and we have just switched to the same nightly for testing also. With the nightly the issue is gone for us as well.
    Really nice that you managed to resolve it that fast.

    Do you have any schedule for when this fix will go to the actual release?

    Thanks,
    Alex

  • alan1903alan1903 Posts: 2Questions: 0Answers: 0

    hi, I have the same issues

    Uncaught RangeError: Maximum call stack size exceeded

    I have imported the css file & js lib mentioned by @vt167098 but it not working for me.

    I have 7000 data with 40++ column

    It working on firefox, but not working in Edge.

    Thank you

  • vt167098vt167098 Posts: 3Questions: 0Answers: 0

    Hi, alan1903:

    I try 9000+ data with 37 cloumns, It's work fine on chrome and edge.

    You can try import below files

      <link href="https://nightly.datatables.net/css/dataTables.dataTables.css" rel="stylesheet" type="text/css" />
        <script src="https://nightly.datatables.net/js/dataTables.js?523492"></script>
     
        <link href="https://cdn.datatables.net/v/dt/jszip-3.10.1/b-3.1.1/b-html5-3.1.1/datatables.min.css" rel="stylesheet">
      
    <script src="https://cdn.datatables.net/v/dt/jszip-3.10.1/b-3.1.1/b-html5-3.1.1/datatables.min.js"></script>
    
    
  • allanallan Posts: 63,489Questions: 1Answers: 10,470 Site admin
    Answer ✓

    I expect to do a release on Friday with the update.

    Allan

  • rnovoarnovoa Posts: 4Questions: 1Answers: 0
    edited August 28

    Hi allan,

    Thank you for addressing this. I was able to test the code the nightly in Chrome and I was successfully able to extract to excel 50k records with 12 columns.

    Looking forward to the release.

  • alan1903alan1903 Posts: 2Questions: 0Answers: 0

    hi @vt167098 . Yes, i did import those file. But still no working.

  • allanallan Posts: 63,489Questions: 1Answers: 10,470 Site admin

    @alan1903 If you link to a page showing the issue I'll take a look and try to debug it.

    Allan

  • rnovoarnovoa Posts: 4Questions: 1Answers: 0

    Hi Allan,

    I have tested on the latest release and the export to Excel button function issue has been resolved.
     
    Thanks,

  • sahariardevsahariardev Posts: 2Questions: 0Answers: 0

    Hi @allan,
    I think We need to do this change in the following function too,

    function _fnFilterCustom( settings )
    {
    var filters = DataTable.ext.search;
    var displayRows = settings.aiDisplay;
    var row, rowIdx;

        for ( var i=0, ien=filters.length ; i<ien ; i++ ) {
            var rows = [];
    
            // Loop over each row and see if it should be included
            for ( var j=0, jen=displayRows.length ; j<jen ; j++ ) {
                rowIdx = displayRows[ j ];
                row = settings.aoData[ rowIdx ];
    
                if ( filters[i]( settings, row._aFilterData, rowIdx, row._aData, j ) ) {
                    rows.push( rowIdx );
                }
            }
    
            // So the array reference doesn't break set the results into the
            // existing array
            displayRows.length = 0;
            displayRows.push.apply(displayRows, rows);
        }
    }
    
  • allanallan Posts: 63,489Questions: 1Answers: 10,470 Site admin
    edited November 10

    Agreed - thanks for flagging that up. I'll make that change tomorrow.

    Out of interest, how many rows do you have?

    Allan

  • sahariardevsahariardev Posts: 2Questions: 0Answers: 0
    edited November 10

    161,933 entries.

    If you want I can create a PR on this.

  • allanallan Posts: 63,489Questions: 1Answers: 10,470 Site admin

    Fix committed here. It will be in 2.1.9 when I release it, which I expect to do later this week.

    Allan

Sign In or Register to comment.