Unexpected end of JSON input



  • I'm getting a really interesting error when I try to render a report. I have identical report data that I'm rendering on both my dev and my production environment. Both of these environments are running off the jsreport docker image and both of them are hosted on Amazon Elastic Beanstalk.

    The only difference I can spot is I have the enterprise license applied in dev where it is not yet applied in production.

    In production I am getting this error:

    Unexpected end of JSON input
    SyntaxError: Unexpected end of JSON input at JSON.parse () at parseGroup (/app/node_modules/jsreport-pdf-utils/lib/utils/parsePdf.js:18:20) at module.exports (/app/node_modules/jsreport-pdf-utils/lib/utils/parsePdf.js:78:25) at processTicksAndRejections (internal/process/task_queues.js:93:5) at async Object.parse (/app/node_modules/jsreport-pdf-utils/lib/utils/pdfManipulator.js:13:28) at async module.exports (/app/node_modules/jsreport-pdf-utils/lib/scriptPdfProcessing.js:49:7)
    

    I have verified the JSON is indeed intact, and if I point my dev environment to run using the production report server, it errors.

    Here's the complete production output: (Redacted the data)

    +0	Starting rendering request 1291 (user: user)
    +2	Rendering template { name: sales-order, recipe: chrome-pdf, engine: handlebars, preview: false }
    +2	Inline data specified.
    +2	Resources not defined for this template.
    +3	Executing script common.js
    +14	Base url not specified, skipping its injection.
    +16	Replaced assets ["common.css","sales-order.css"]
    +16	Rendering engine handlebars
    +23	Taking compiled template from engine cache
    +23	Pdf utils adding item field, value: 183350
    +24	Pdf utils adding group field, value: 
    +24	Pdf utils adding item field, value: 187585
    +24	Pdf utils adding group field, value: 
    +24	Pdf utils adding item field, value: 184655
    +24	Pdf utils adding group field, value: 
    +24	Pdf utils adding item field, value: 184880
    +25	Pdf utils adding group field, value: 
    +25	Pdf utils adding item field, value: 187312
    +25	Pdf utils adding group field, value: 
    +25	Pdf utils adding item field, value: 186023
    +25	Pdf utils adding group field, value: 
    +25	Pdf utils adding item field, value: 184175
    +25	Pdf utils adding group field, value: 
    +25	Pdf utils adding item field, value: 187582
    +26	Pdf utils adding group field, value: 
    +26	Pdf utils adding item field, value: 187552
    +26	Pdf utils adding group field, value: 
    +26	Pdf utils adding item field, value: 187635
    +26	Pdf utils adding group field, value: 
    +26	Pdf utils adding item field, value: 184807
    +26	Pdf utils adding group field, value: 
    +26	Pdf utils adding item field, value: 183607
    +27	Pdf utils adding group field, value: 
    +27	Pdf utils adding item field, value: 184521
    +27	Pdf utils adding group field, value: 
    +27	Pdf utils adding item field, value: 183528
    +27	Pdf utils adding group field, value: 
    +27	Pdf utils adding item field, value: 185088
    +27	Pdf utils adding group field, value: 
    +27	Pdf utils adding item field, value: 183373
    +28	Pdf utils adding group field, value: 
    +51	Executing recipe chrome-pdf
    +231	Converting with chrome HeadlessChrome/76.0.3809.132 using dedicated-process strategy
    +747	Running chrome with params {"marginTop":".5cm","marginRight":".5cm","marginBottom":"2cm","marginLeft":".5cm","margin":{"top":".5cm","right":".5cm","bottom":"2cm","left":".5cm"},"printBackground":true}
    +1938	pdf-utils is starting pdf processing
    

    And here is my complete dev output:

    +0	Starting rendering request 21 (user: user)
    +1	Rendering template { name: sales-order, recipe: chrome-pdf, engine: handlebars, preview: false }
    +2	Inline data specified.
    +2	Resources not defined for this template.
    +3	Executing script common.js
    +26	Base url not specified, skipping its injection.
    +28	Replaced assets ["common.css","sales-order.css"]
    +28	Rendering engine handlebars
    +35	Taking compiled template from engine cache
    +36	Pdf utils adding item field, value: 183350
    +36	Pdf utils adding group field, value: 
    +36	Pdf utils adding item field, value: 187585
    +36	Pdf utils adding group field, value: 
    +36	Pdf utils adding item field, value: 184655
    +37	Pdf utils adding group field, value: 
    +37	Pdf utils adding item field, value: 184880
    +37	Pdf utils adding group field, value: 
    +37	Pdf utils adding item field, value: 187312
    +37	Pdf utils adding group field, value: 
    +37	Pdf utils adding item field, value: 186023
    +37	Pdf utils adding group field, value: 
    +37	Pdf utils adding item field, value: 184175
    +38	Pdf utils adding group field, value: 
    +38	Pdf utils adding item field, value: 187582
    +38	Pdf utils adding group field, value: 
    +38	Pdf utils adding item field, value: 187552
    +38	Pdf utils adding group field, value: 
    +38	Pdf utils adding item field, value: 187635
    +39	Pdf utils adding group field, value: 
    +39	Pdf utils adding item field, value: 184807
    +39	Pdf utils adding group field, value: 
    +39	Pdf utils adding item field, value: 183607
    +39	Pdf utils adding group field, value: 
    +39	Pdf utils adding item field, value: 184521
    +39	Pdf utils adding group field, value: 
    +39	Pdf utils adding item field, value: 183528
    +40	Pdf utils adding group field, value: 
    +40	Pdf utils adding item field, value: 185088
    +40	Pdf utils adding group field, value: 
    +40	Pdf utils adding item field, value: 183373
    +40	Pdf utils adding group field, value: 
    +46	Executing recipe chrome-pdf
    +204	Converting with chrome HeadlessChrome/76.0.3809.132 using dedicated-process strategy
    +707	Running chrome with params {"marginTop":".5cm","marginRight":".5cm","marginBottom":"2cm","marginLeft":".5cm","margin":{"top":".5cm","right":".5cm","bottom":"2cm","left":".5cm"},"printBackground":true}
    +1902	pdf-utils is starting pdf processing
    +1907	Detected 1 pdf operation(s) to process
    +2284	Running pdf operation merge
    +2285	Starting rendering request 22 (user: chipply)
    +2286	Rendering template { name: sales-order-footer, recipe: chrome-pdf, engine: handlebars, preview: false }
    +2287	Inline data specified.
    +2287	Resources not defined for this template.
    +2288	Base url not specified, skipping its injection.
    +2289	Replaced assets ["sales-order.css"]
    +2289	Rendering engine handlebars
    +2301	Taking compiled template from engine cache
    +2303	Executing recipe chrome-pdf
    +2433	Converting with chrome HeadlessChrome/76.0.3809.132 using dedicated-process strategy
    +2721	Running chrome with params {"marginTop":"","marginLeft":"1cm","marginRight":"1cm","margin":{"top":"","right":"1cm","left":"1cm"},"printBackground":true}
    +2791	Skipping storing report.
    +2792	Rendering request 22 finished in 507 ms
    +2966	pdf-utils pdf processing was finished
    +2971	Skipping storing report.
    +2987	Rendering request 21 finished in 2987 ms
    


  • Hm, this will be difficult.

    I see you are using pdfCreatePagesGroup helper. This adds to the pdf an almost invisible text which we parse during the merge operation and provide it to you so you can use it for dynamic headers and so on. It seems that in your case, the added text got somehow malformed and we fail to read it during the merge.
    You see the crash on this line.
    https://github.com/jsreport/jsreport-pdf-utils/blob/master/lib/utils/parsePdf.js#L18

    It would give us probably more clue on the problem if you would connect to your prod image, edit this line with some try catch throwing in error what is being actually JSON.parsed, then restarted container and render again.

    I guess you are not able to replicate the problem in our playground by a chance.
    https://playground.jsreport.net/



  • Thanks Jan,

    I ended up doing a deploy to production with the Enterprise license applied. For some reason, the deploy fixed it.

    I'll look into this further on this thread with your suggestions if I run into this again!


Log in to reply
 

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