JSReport 1.x exception when rendering report that contains S3 image links



  • We have a report that contains a lot of images with S3 (signed) image links. Sometimes we get the exception below:

    Jan 25     at onCriticalError (/usr/local/var/jsreport/node_modules/jsreport-cli/lib/commands/render.js:302:25)
         at tryCatcher (/usr/local/var/jsreport/node_modules/jsreport-cli/node_modules/bluebird/js/release/util.js:16:23)
         at Promise._settlePromiseFromHandler (/usr/local/var/jsreport/node_modules/jsreport-cli/node_modules/bluebird/js/release/promise.js:510:31)
         at Promise._settlePromise (/usr/local/var/jsreport/node_modules/jsreport-cli/node_modules/bluebird/js/release/promise.js:567:18)
         at Promise._settlePromise0 (/usr/local/var/jsreport/node_modules/jsreport-cli/node_modules/bluebird/js/release/promise.js:612:10)
         at Promise._settlePromises (/usr/local/var/jsreport/node_modules/jsreport-cli/node_modules/bluebird/js/release/promise.js:687:18)
         at Async._drainQueue (/usr/local/var/jsreport/node_modules/jsreport-cli/node_modules/bluebird/js/release/async.js:133:16)
         at Async._drainQueues (/usr/local/var/jsreport/node_modules/jsreport-cli/node_modules/bluebird/js/release/async.js:143:10)
         at Immediate.Async.drainQueues (/usr/local/var/jsreport/node_modules/jsreport-cli/node_modules/bluebird/js/release/async.js:17:14)
         at runCallback (timers.js:810:20)
         at tryOnImmediate (timers.js:768:5)
         at processImmediate [as _immediateCallback] (timers.js:745:5) {"originalError":{"remoteStack":"Error: Command failed: /usr/local/var/jsreport/node_modules/wkhtmltopdf-installer/vendor/wkhtmltopdf --debug-javascript --disable-local-file-access --dpi 96 --javascript-delay 3000 --page-size Letter --margin-bottom 4mm --margin-top 6mm /tmp/jsreport/c86f6750-20be-11e9-ad8b-6d055ad2d848.html /tmp/jsreport/c86f6750-20be-11e9-ad8b-6d055ad2d848.pdf\nLoading pages (1/6)\n[>                                                           ] 0%\r[======>                                                     ] 10%\r[====================>                                       ] 34%\r[========================>                                   ] 40%\r[=========================>                                  ] 43%\r[===========================>                                ] 46%\r[=============================>                              ] 49%\r[==============================>                             ] 51%\r[====================================>                       ] 60%\r[=======================================>                    ] 65%\r[==========================================>                 ] 71%\r[=============================================>              ] 75%\r[==============================================>             ] 77%\r[=================================================>          ] 83%\r[===================================================>        ] 85%\r[============================================================] 100%\rCounting pages (2/6)                                               \n[============================================================] Object 1 of 1\rResolving links (4/6)                                                       \n[============================================================] Object 1 of 1\rLoading headers and footers (5/6)                                           \nPrinting pages (6/6)\n[>                                                           ] Preparing\r[===============>                                            ] Page 1 of 4\r[==============================>                             ] Page 2 of 4\r[=============================================>              ] Page 3 of 4\r[============================================================] Page 4 of 4\rDone                                                                      \nExit with code 1 due to network error: ContentNotFoundError\n\n    at ChildProcess.exithandler (child_process.js:276:12)\n    at emitTwo (events.js:126:13)\n    at ChildProcess.emit (events.js:214:7)\n    at maybeClose (internal/child_process.js:915:16)\n    at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)"}}
    (Original) Error: Error during rendering report: Command failed: /usr/local/var/jsreport/node_modules/wkhtmltopdf-installer/vendor/wkhtmltopdf --debug-javascript --disable-local-file-access --dpi 96 --javascript-delay 3000 --page-size Letter --margin-bottom 4mm --margin-top 6mm /tmp/jsreport/c86f6750-20be-11e9-ad8b-6d055ad2d848.html /tmp/jsreport/c86f6750-20be-11e9-ad8b-6d055ad2d848.pdf
     Loading pages (1/6)
     [>                                                           ] 0%
     [======>                                                     ] 10%
     [====================>                                       ] 34%
     [========================>                                   ] 40%
     [=========================>                                  ] 43%
     [===========================>                                ] 46%
     [=============================>                              ] 49%
     [==============================>                             ] 51%
     [====================================>                       ] 60%
     [=======================================>                    ] 65%
     [==========================================>                 ] 71%
     [=============================================>              ] 75%
     [==============================================>             ] 77%
     [=================================================>          ] 83%
     [===================================================>        ] 85%
     [============================================================] 100%
     Counting pages (2/6)                                               
     [============================================================] Object 1 of 1
     Resolving links (4/6)                                                       
     [============================================================] Object 1 of 1
     Loading headers and footers (5/6)                                           
     Printing pages (6/6)
     [>                                                           ] Preparing
     [===============>                                            ] Page 1 of 4
     [==============================>                             ] Page 2 of 4
     [=============================================>              ] Page 3 of 4
     [============================================================] Page 4 of 4
     Done                                                                      
     Exit with code 1 due to network error: ContentNotFoundError
     
         at /usr/local/var/jsreport/node_modules/jsreport-client/lib/client.js:64:23
        at ConcatStream.<anonymous> (/usr/local/var/jsreport/node_modules/jsreport-client/node_modules/concat-stream/index.js:36:43)
        at emitNone (events.js:111:20)
        at ConcatStream.emit (events.js:208:7)
        at finishMaybe (/usr/local/var/jsreport/node_modules/jsreport-client/node_modules/readable-stream/lib/_stream_writable.js:475:14)
        at afterWrite (/usr/local/var/jsreport/node_modules/jsreport-client/node_modules/readable-stream/lib/_stream_writable.js:361:3)
        at _combinedTickCallback (internal/process/next_tick.js:145:20)
        at process._tickCallback (internal/process/next_tick.js:181:9) {"remoteStack":"Error: Command failed: /usr/local/var/jsreport/node_modules/wkhtmltopdf-installer/vendor/wkhtmltopdf --debug-javascript --disable-local-file-access --dpi 96 --javascript-delay 3000 --page-size Letter --margin-bottom 4mm --margin-top 6mm /tmp/jsreport/c86f6750-20be-11e9-ad8b-6d055ad2d848.html /tmp/jsreport/c86f6750-20be-11e9-ad8b-6d055ad2d848.pdf\nLoading pages (1/6)\n[>                                                           ] 0%\r[======>                                                     ] 10%\r[====================>                                       ] 34%\r[========================>                                   ] 40%\r[=========================>                                  ] 43%\r[===========================>                                ] 46%\r[=============================>                              ] 49%\r[==============================>                             ] 51%\r[====================================>                       ] 60%\r[=======================================>                    ] 65%\r[==========================================>                 ] 71%\r[=============================================>              ] 75%\r[==============================================>             ] 77%\r[=================================================>          ] 83%\r[===================================================>        ] 85%\r[============================================================] 100%\rCounting pages (2/6)                                               \n[============================================================] Object 1 of 1\rResolving links (4/6)                                                       \n[============================================================] Object 1 of 1\rLoading headers and footers (5/6)                                           \nPrinting pages (6/6)\n[>                                                           ] Preparing\r[===============>                                            ] Page 1 of 4\r[==============================>                             ] Page 2 of 4\r[=============================================>              ] Page 3 of 4\r[============================================================] Page 4 of 4\rDone                                                                      \nExit with code 1 due to network error: ContentNotFoundError\n\n    at ChildProcess.exithandler (child_process.js:276:12)\n    at emitTwo (events.js:126:13)\n    at ChildProcess.emit (events.js:214:7)\n    at maybeClose (internal/child_process.js:915:16)\n    at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)"}
    


  • Hi,

    try to search in wkhtmltopdf github issues. Perhaps you find there some information

    https://github.com/wkhtmltopdf/wkhtmltopdf/search?q=ContentNotFoundError&type=Issues



  • it happens on the image that cannot be retrieved. Seems to be an issue in the wkhtmltopdf, is there any way to try a newer version of it with JSReport 1.x?



  • Yes, replace the binary here
    /usr/local/var/jsreport/node_modules/wkhtmltopdf-installer/vendor/wkhtmltopdf



  • Thank you, is there any way to pass additional flags to it from jsreport?



  • I think this should work in config

    {
       ...
       "wkhtmltopdf": {
         "specialOption": "optionValue"
       }
    }
    

    However since you are anyway troubleshooting for now, you can edit the code directly and add the option somewhere here
    https://github.com/jsreport/jsreport-wkhtmltopdf/blob/master/lib/wkhtmltopdf.js#L67



  • Is there a way to write a helper that would check if a particular link (image) would return 404 when requested? The wkhtmltopdf seems to be still broken even at the latest version.



  • The helpers are synchronous and I am not sure if the node.js has API for sync http calls.

    However, you should be able to write jsreport sccript that downloads the images in advance and then you can pass it as base64 to the handlebars and fill the images. This won't be the best performing option. It will take also some time to implement. However, it will probably work. Maybe the wkhtmltopdf just makes too many parallel requests and AWS rejects some. With jsreport sccript you have the option to control this.



  • Thank you, I think just replacing broken links with empty URLs should be fine in my case.


Log in to reply
 

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