Can't get jsreport to run using jsreport start


  • administrators

    i think the only way to do it in the version of jsreport you have (1.6.0) is by adding the following line at the top of your server.js file

    process.env.NODE_ENV='development' // this will make it use dev.config.json
    // process.env.NODE_ENV='production' // this will make it use prod.config.json
    


  • Or read file manually in server.js and pass it to jsreport :)

    const jsreport = require('jsreport')(JSON.parse(fs.readFileSync('myconfig.json').toString())
    


  • This first option worked great =)
    My issue was/is that I have a PM2 server watching to make sure jsreport doesn't go down, but when I tell pm2 to start my server.js file, everything starts up but it doesn't seem to pick my my prod.config.json, so it was running on the wrong port and lost the rest of my config options. It didn't seem to be picking up either of configs.. because both my dev and prod config files define my port as 4201.. but it started on the default port of 5488.



  • Any idea why last week I my Angular app was connecting to jsreport and generating PDFs fine, and now I check it today and when I try to render a report I get this error:
    "Error during rendering report: Unexpected end of JSON input"

    I haven't made any changes to it since since it last worked.



  • Currently we have a bug that can cause inconsistency in underlying data in some edge cases.
    Please try to backup/remove files in the root of the data folder and start again.
    Usually the inconsistency is in the settings file which anyway contains just some logs.



  • Ah sorry. I didn't read it carefully. The bug I was mentioning is in v2 and would produce different error. Please ignore previous comment. :)



  • I just tried our Dev server (my other post was for our Prod server) and I'm getting the same error there. Dev has been working fine for months.
    Any hints as to where to look exactly for what might be causing this issue suddenly?



  • Try to give us full output, it should be also in logs.


  • administrators

    Any idea why last week I my Angular app was connecting to jsreport and generating PDFs fine, and now I check it today and when I try to render a report I get this error:
    "Error during rendering report: Unexpected end of JSON input"
    I haven't made any changes to it since since it last worked.

    hmm does this happens too if you open jsreport studio and try to render something? (it is just some check to see that there is no jsreport entity corrupted) so far it looks to me that this is caused by sending some bad json from your angular app, a quick check can be to try to render something from studio, if it works there then probably your angular app is sending bad data in some case.



  • This is all it says:
    Error occured - Error during rendering report: Unexpected end of JSON input Stak - SyntaxError: Unexpected end of JSON input at Object.parse (native) at IncomingMessage.result.on (evalmachine.<anonymous>:13:46) at emitNone (events.js:91:20) at IncomingMessage.emit (events.js:185:7) at endReadableNT (_stream_readable.js:978:12) at _combinedTickCallback (internal/process/next_tick.js:80:11) at process._tickCallback (internal/process/next_tick.js:104:9)

    What's weird is that my app is bilingual. English and French use the same JSON that is sent to 2 different templates, one for EN and one for FR. When I send to the FR template it works, but when I send to the EN it gives this error. The ONLY thing that's different about the JSON being sent to both of these templates is the template var that is either set the EN's template ID or the FR template's ID.. that's it. And I've checked to make sure the EN template ID is correct, it is. The rest of the body data is exactly the same. Could there be something in the markup of a template that could cause this error?


  • administrators

    hmm i don't any clue so far, apparently the error message tells that there is bad json in incoming request, so if you say the the request for FR works and not the EN then it makes me think that the request for EN is somehow bad, but if you are 100% sure that both request are the same and just the template id changes then you can try start removing content (parts of your template) and other things referenced from you EN template until you find that it pass, it you get to a point that the template is totally empty (no scripts attached, just some simple message like "Hello world") and the request still does not pass then the problem is (100% sure) the request that your angular app is doing and you will need to do in depth debugging to your app to find out the problem. (of course before changing your EN template for the test make sure to do a copy so you don't loose your original content)



  • I fixed it!
    Although I don't know why what I did worked.

    Turns out it was something with my English template. I made a new template and literally copied and pasted all the info from my original EN template to the my new one and changed the template ID in my app and it started working. If I change the ID back the old EN template I get those errors. So somewhere along the way something happened to that template, but it's not in the markup since I copied all that into the new template and that works fine. It must be something else somewhere in files that we don't touch.
    Weird.


Log in to reply
 

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