Jsreport doesn't work for large files html-to-xlsx



  • Hello i am using using js-report with node js.
    It work perfectly for small files but when i want to generate a report of 36MB i get many errors of templating engine timeout and script evaluation timeout.
    After adding this config i get a phantomjs problem this what i get:

    error: Error when processing render request Command failed: C:\Users\...\jsReport1.0\jsreport\node_modules\phantomjs\lib\phantom\bin\phantomjs.exe --ignore-ssl-errors=yes --web-security=false --ssl-protocol=any C:\Users\....\jsReport1.0\jsreport\node_modules\phantom-page-eval\lib\scripts\runPage.js C:\...\AppData\Local\Temp\jsreport\autocleanup\yHzs8WT-eval-input.json
    Fatal Windows exception, code 0xc0000005.
    PhantomJS has crashed. Please read the bug reporting guide at
    <http://phantomjs.org/bug-reporting.html> and file a bug report.
     Error: Command failed: C:\Users\...\jsReport1.0\jsreport\node_modules\phantomjs\lib\phantom\bin\phantomjs.exe --ignore-ssl-errors=yes --web-security=false --ssl-protocol=any C:\Users......\jsReport1.0\jsreport\node_modules\phantom-page-eval\lib\scripts\runPage.js C:\....\AppData\Local\Temp\jsreport\autocleanup\yHzs8WT-eval-input.json
    Fatal Windows exception, code 0xc0000005.
    PhantomJS has crashed. Please read the bug reporting guide at
    <http://phantomjs.org/bug-reporting.html> and file a bug report.
    
        at ChildProcess.exithandler (child_process.js:295:12)
        at ChildProcess.emit (events.js:209:13)
        at maybeClose (internal/child_process.js:1021:16)
        at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)
    (node:48948) UnhandledPromiseRejectionWarning: Error: Command failed: C:\Users\....\jsReport1.0\jsreport\node_modules\phantomjs\lib\phantom\bin\phantomjs.exe --ignore-ssl-errors=yes --web-security=false --ssl-protocol=any C:\Users\....\jsReport1.0\jsreport\node_modules\phantom-page-eval\lib\scripts\runPage.js C:\Users\...\AppData\Local\Temp\jsreport\autocleanup\yHzs8WT-eval-input.json
    Fatal Windows exception, code 0xc0000005.
    PhantomJS has crashed. Please read the bug reporting guide at
    <http://phantomjs.org/bug-reporting.html> and file a bug report.
    
        at ChildProcess.exithandler (child_process.js:295:12)
        at ChildProcess.emit (events.js:209:13)
        at maybeClose (internal/child_process.js:1021:16)
        at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)
    (node:48948) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id:
    1)
    (node:48948) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
    

    This is my configuration:

    {   "http": 5488,
        "store": { "provider": "memory" },
        "allowLocalFilesAccess": true,
        "blobStorage": { "provider": "fs" },
        "logger": {
          "console": {
            "transport": "console",
            "level": "debug"
          }
        },
        "chrome": {
          "timeout": 300000000
        },
        "templatingEngines": {
          "numberOfWorkers" : 4,
          "timeout": 300000000,
          "strategy": "in-process",
          "allowedModules": "*"
        },
        "extensions":  {  
            "templatingEngines": {
             
                "timeout": 300000000,
              },
          "authentication"  :  {  
            "cookieSession":  {  
              "secret":  "dasd321as56d1sd5s61vdv32"  
            },  
            "admin":  {  
              "username": "admin",
              "password": "password"  
            }  
          },
          "html-to-xlsx": {
            "timeout": 300000000,
            "strategy": "in-process",
            "htmlEngine": "chrome"
          },
          "htmlToXlsx": {
            "strategy": "in-process",
            "htmlEngine": "chrome"
          },
          "scripts": {
            "timeout": 300000000
          },
          "express": {
            "timeout": 300000000,
            "inputRequestLimit": "500mb"
          }
       },
       "template": {
        "htmlEngine": "chrome"
       },
       "express": {
         "timeout": 300000000
       }
    }
    

    This is my code:

    jsreport.use(jsreportHandelbars())
                            .use(jsreportHtmlToDocx())
                            .use(jsreportChromePdf({}))
                            .use(jsreportHtmlToXlsx())
                            .use(jsreportHtml())
                            .use(jsreportXlsx())
                            .use(pdfUtils())
                            .use(jsreportAssets({
                                "publicAccessEnabled": true,
                                "allowedFiles": "**",
                                "searchOnDiskIfNotFoundInStore": true,
                                })
                            );
                    jsreport.init().then(() => {
                        const templateFile = {
                            //Htmlfile extracted from the zip file is our content 
                            content: fs.readFileSync(path.join(htmlFile),'utf8').toString(),
                            recipe: typeDoc,
                            engine: "handlebars"
                        };
                        if (jsFile) templateFile.helpers = fs.readFileSync(path.join(jsFile),'utf8').toString();
                        jsreport.render({
                            template: templateFile,
                            //Jsonfile extracted from the zip file is our data 
                            data: fs.readFileSync(path.join(jsonFile),'utf8').toString()
                        })
                        .then((resp) => {   
    let extension;
                            const typeDocs = {
                                'chrome-pdf':'.pdf',
                                'html-to-xlsx':'.xlsx',
                                'xlsx':'.xlsx',
                                'html-with-browser-client':'.html',
                                'html-embedded-in-docx':'.docx'
                            };
                            if (!Object.keys(typeDocs).includes(typeDoc)) {
                                return (Boom.badData('TYPE_DOC_IS_NOT_DEFINED'));
                            }
                            extension = typeDocs[typeDoc];
                            if (extension) {
                                fs.writeFileSync((reportPath.concat(extension)), resp.content);
                                res.download((reportPath.concat(extension)));
                            }
    });
    


  • It is quite strange you get a phantomjs error when it seems you are linking chrome.

    Could you try to run the same template in the default on prem jsreport instance?
    Installed using default installation steps https://jsreport.net/on-prem
    There should run chrome engine to evaluate your html before it is converted to the xlsx.



  • Using default configuration i have error of: Engine template timeout and after editing engines template i had scripts timeout error.


Log in to reply
 

Looks like your connection to jsreport forum was lost, please wait while we try to reconnect.