Jsreport example run fail



  • Hi all,
    on a local virtual machine with debian 12 I installed jsreport through an ansible playbook, in which I report here some steps:

    • name: Install and Configure JsReport | Install "jsreport" node.js package globally.
      become: true
      npm:
      name: "@jsreport/jsreport-cli"
      global: yes
      register: jsreportinstall

    • name: Creates directory
      become: true
      ansible.builtin.file:
      path: /var/apps/jsreportapp
      state: directory
      owner: pm2
      group: pm2

    • name: Assign owner to /tmp/jsreport
      become: true
      ansible.builtin.file:
      path: /tmp/jsreport
      recurse: yes
      owner: pm2
      group: pm2

    • name: JsReport init
      ansible.builtin.command: jsreport init
      become: true
      become_user: pm2
      args:
      chdir: /var/apps/jsreportapp

    • name: JsReport config
      become: true
      template:
      src: jsreport.config.json.j2
      dest: /var/apps/jsreportapp/jsreport.config.json
      owner: pm2
      group: pm2
      mode: "u=r,g=r,o="

    • name: Check if PM2 process is running
      become: true
      become_user: pm2
      command: 'pm2 show jsreport-server'
      register: pm2_status
      ignore_errors: true

    • name: JsReport | Start pm2 process
      become: true
      become_user: pm2
      command: 'pm2 start server.js -i 1 -n jsreport-server' #max use 1 process for each cpu
      when: "'status' not in pm2_status.stdout"
      args:
      chdir: "/var/apps/jsreportapp"
      register: pm2save
      failed_when: pm2save.rc != 0

    • name: Reload PM2 process
      become: true
      become_user: pm2
      command: 'pm2 reload jsreport-server'
      when: "'status' in pm2_status.stdout and 'online' in pm2_status.stdout"

    • name: Install and Configure PM2 | Configure PM2 startup hook
      become: true
      command: "su -c 'pm2 save' pm2"
      when: "pm2save.changed"
      register: pm2persistence
      failed_when: "'skipping save' in pm2persistence.stdout"

    the installation was successful and jsreport execution is through pm2, as indicated in the ansible playbook.
    Visiting the host on the relevant port, I arrive on the jsreport homepage.
    However, if I try to launch, for example, the "invoice-main" example template, I get, alternately, two errors:
    The first:
    error: Error when processing render request 12 1|jsreport-server | (because) could not find Chrome (ver. 122.0.6261.111). This can occur if either 1|jsreport-server | 1. you did not perform an installation before running the script (e.g.npx puppeteer browsers install chrome) or 1|jsreport-server | 2. your cache path is incorrectly configured (which is: /var/apps/.cache/puppeteer). 1|jsreport-server | For (2), check out our guide on configuring puppeteer at https://pptr.dev/guides/configuration. 1|jsreport-server | Error: Could not find Chrome (ver. 122.0.6261.111). This can occur if either 1|jsreport-server | 1. you did not perform an installation before running the script (e.g.npx puppeteer browsers install chrome) or 1|jsreport-server | 2. your cache path is incorrectly configured (which is: /var/apps/.cache/puppeteer).

    The second:
    2024-06-18T13:27:02.552Z - info: Render request 13 queued for execution and waiting for available worker rootId=1gtv6545nmiz216, id=1gtv6545nmiz216 1|jsreport-server | 2024-06-18T13:27:02.564Z - info: Starting rendering request 13 rootId=1gtv6545nmiz216, id=1gtv6545nmiz216 1|jsreport-server | 2024-06-18T13:27:02.564Z - info: Rendering template { name: invoice-main, recipe: chrome-pdf, engine: handlebars, preview: true } rootId=1gtv6545nmiz216, id=1gtv6545nmiz216 1|jsreport-server | 2024-06-18T13:27:02.564Z - debug: Adding sample data Sy5S19ncg rootId=1gtv6545nmiz216, id=1gtv6545nmiz216 1|jsreport-server | 2024-06-18T13:27:02.564Z - debug: Base url not specified, skipping its injection. rootId=1gtv6545nmiz216, id=1gtv6545nmiz216 1|jsreport-server | 2024-06-18T13:27:02.565Z - debug: Rendering engine handlebars rootId=1gtv6545nmiz216, id=1gtv6545nmiz216 1|jsreport-server | 2024-06-18T13:27:02.636Z - debug: (console:log) Calculating item Website design; you should see this message in debug run userLevel=true, rootId=1gtv6545nmiz216, id=1gtv6545nmiz216 1|jsreport-server | 2024-06-18T13:27:02.637Z - debug: Executing recipe chrome-pdf rootId=1gtv6545nmiz216, id=1gtv6545nmiz216 1|jsreport-server | 2024-06-18T13:27:54.552Z - warn: Report render failed 1|jsreport-server | (because) report timeout. Last profiler operation: (recipe) chrome-pdf. You can inspect and find more details here: http://debian12-test:5488/studio/profiles/JF5FRYEhi3KuXFAP 1|jsreport-server | Error: Report timeout. Last profiler operation: (recipe) chrome-pdf. You can inspect and find more details here: http://debian12-test:5488/studio/profiles/JF5FRYEhi3KuXFAP 1|jsreport-server | at Timeout.<anonymous> (/var/apps/jsreportapp/node_modules/@jsreport/advanced-workers/lib/threadWorker.js:43:23) 1|jsreport-server | at listOnTimeout (node:internal/timers:569:17) 1|jsreport-server | at process.processTimers (node:internal/timers:512:7) rootId=1gtv6545nmiz216, id=1gtv6545nmiz216

    I always get these errors alternately. I've tried everything, installing libraries, puppeteer, all the solutions written and indicated everywhere, but I can't get to the bottom of it.
    Has anyone had the same situation?
    Thank you very much for the support, I really appreciate it



  • It seems the app is installed using a different user from the user that runs it. Can't this be the case?



  • Hi, thank you so much for the answer. I don't think so, in fact seems to be relegated to some extension like chrome-pdf.
    Here a report of error displayed:

    `Report "invoice-main" render failed.

    Failed to launch the browser process!
    /var/apps/.cache/puppeteer/chrome/linux-124.0.6367.207/chrome-linux64/chrome: error while loading shared libraries: libatk-1.0.so.0: cannot open shared object file: No such file or directory

    TROUBLESHOOTING: https://pptr.dev/troubleshooting

    Error: Failed to launch the browser process!
    /var/apps/.cache/puppeteer/chrome/linux-124.0.6367.207/chrome-linux64/chrome: error while loading shared libraries: libatk-1.0.so.0: cannot open shared object file: No such file or directory

    TROUBLESHOOTING: https://pptr.dev/troubleshooting

    at Interface.onClose (/var/apps/jsreportapp/node_modules/@puppeteer/browsers/lib/cjs/launch.js:310:24)
    at Interface.emit (node:events:526:35)
    at Interface.close (node:internal/readline/interface:533:10)
    at Socket.onend (node:internal/readline/interface:259:10)
    at Socket.emit (node:events:526:35)
    at endReadableNT (node:internal/streams/readable:1359:12)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)`


  • I see... chrome typically doesn't have all dependencies installed on Linux servers.
    Try to check this installation guide
    https://jsreport.net/learn/ubuntu


Log in to reply
 

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