codimd icon indicating copy to clipboard operation
codimd copied to clipboard

Crash when trying to export to PDF

Open kalon33 opened this issue 2 years ago • 7 comments

When trying to export to PDF, for example the "Features" document, it crashes:

codimd_1    | 2022-08-09T15:29:54.388Z error:   uncaughtException: Command failed: /home/hackmd/app/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs /home/hackmd/app/node_modules/markdown-pdf/ph
antom/render.js /tmp/tmp-23T217YkHOtWhW.html /tmp/tmp-238Mg00jNGpimx.pdf /home/hackmd/app /home/hackmd/app/node_modules/markdown-pdf/runnings.js /home/hackmd/app/node_modules/markdown-pdf/css/pdf.css /ho
me/hackmd/app/node_modules/highlight.js/styles/github-gist.css A4 portrait 2cm 0 10000                                                                                                                     
codimd_1    | This application failed to start because it could not find or load the Qt platform plugin "offscreen".                                                                                       
codimd_1    |                                                                                                                                                                                              
codimd_1    | Available platform plugins are: phantom.                                                                                                                                                     
codimd_1    |                                                                                                                                                                                              
codimd_1    | Reinstalling the application may fix this problem.                                                                                                                                           
codimd_1    | PhantomJS has crashed. Please read the bug reporting guide at                                                                                                                                
codimd_1    | <http://phantomjs.org/bug-reporting.html> and file a bug report.                                                                                                                             
codimd_1    |                                                                                                                                                                                              
codimd_1    | Error: Command failed: /home/hackmd/app/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs /home/hackmd/app/node_modules/markdown-pdf/phantom/render.js /tmp/tmp-23T217YkHOtWhW.html /
tmp/tmp-238Mg00jNGpimx.pdf /home/hackmd/app /home/hackmd/app/node_modules/markdown-pdf/runnings.js /home/hackmd/app/node_modules/markdown-pdf/css/pdf.css /home/hackmd/app/node_modules/highlight.js/styles
/github-gist.css A4 portrait 2cm 0 10000                                                                                                                                                                   
codimd_1    | This application failed to start because it could not find or load the Qt platform plugin "offscreen".                                                                                       
codimd_1    |                                                                                                                                                                                              
codimd_1    | Available platform plugins are: phantom.                                                                                                                                                     
codimd_1    | 
codimd_1    | Reinstalling the application may fix this problem.                                                                                                                                  
codimd_1    | PhantomJS has crashed. Please read the bug reporting guide at                                                                                                                                
codimd_1    | <http://phantomjs.org/bug-reporting.html> and file a bug report.                                                                                                                             
codimd_1    |                                                                                                                                                                                              
codimd_1    |     at ChildProcess.exithandler (child_process.js:294:12)                                                                                                                                    
codimd_1    |     at ChildProcess.emit (events.js:198:13)                                                                                                                                                  
codimd_1    |     at maybeClose (internal/child_process.js:982:16)                                                                                                                                         
codimd_1    |     at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)                                                                                                                 
codimd_1    | 2022-08-09T15:29:54.388Z error:   An uncaught exception has occured.                                                                                                                         
codimd_1    | 2022-08-09T15:29:54.388Z error:   Command failed: /home/hackmd/app/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs /home/hackmd/app/node_modules/markdown-pdf/phantom/render.js /tm
p/tmp-23T217YkHOtWhW.html /tmp/tmp-238Mg00jNGpimx.pdf /home/hackmd/app /home/hackmd/app/node_modules/markdown-pdf/runnings.js /home/hackmd/app/node_modules/markdown-pdf/css/pdf.css /home/hackmd/app/node_
modules/highlight.js/styles/github-gist.css A4 portrait 2cm 0 10000                                                                                                                                        
codimd_1    | This application failed to start because it could not find or load the Qt platform plugin "offscreen".                                                                                       
codimd_1    |                                                                                                                                                                                              
codimd_1    | Available platform plugins are: phantom.                                                                                                                                                     
codimd_1    |                                                                                                                                                                                              
codimd_1    | Reinstalling the application may fix this problem.
codimd_1    | PhantomJS has crashed. Please read the bug reporting guide at
codimd_1    | <http://phantomjs.org/bug-reporting.html> and file a bug report.
codimd_1    | 
codimd_1    | { Error: Command failed: /home/hackmd/app/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs /home/hackmd/app/node_modules/markdown-pdf/phantom/render.js /tmp/tmp-23T217YkHOtWhW.html /tmp/tmp-238Mg00jNGpimx.pdf /home/hackmd/app /home/hackmd/app/node_modules/markdown-pdf/runnings.js /home/hackmd/app/node_modules/markdown-pdf/css/pdf.css /home/hackmd/app/node_modules/highlight.js/styles/github-gist.css A4 portrait 2cm 0 10000
codimd_1    | This application failed to start because it could not find or load the Qt platform plugin "offscreen".
codimd_1    | 
codimd_1    | Available platform plugins are: phantom.
codimd_1    | 
codimd_1    | Reinstalling the application may fix this problem.
codimd_1    | PhantomJS has crashed. Please read the bug reporting guide at
codimd_1    | <http://phantomjs.org/bug-reporting.html> and file a bug report.
codimd_1    | 
codimd_1    |     at ChildProcess.exithandler (child_process.js:294:12)
codimd_1    |     at ChildProcess.emit (events.js:198:13)
codimd_1    |     at maybeClose (internal/child_process.js:982:16)
codimd_1    |     at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
codimd_1    |   killed: false,
codimd_1    |   code: null,
codimd_1    |   signal: 'SIGABRT',
codimd_1    |   cmd:
codimd_1    |    '/home/hackmd/app/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs /home/hackmd/app/node_modules/markdown-pdf/phantom/render.js /tmp/tmp-23T217YkHOtWhW.html /tmp/tmp-238Mg00jNGpimx.pdf /home/hackmd/app /home/hackmd/app/node_modules/markdown-pdf/runnings.js /home/hackmd/app/node_modules/markdown-pdf/css/pdf.css /home/hackmd/app/node_modules/highlight.js/styles/github-gist.css A4 portrait 2cm 0 10000',
codimd_1    |   level: 'error',
codimd_1    |   timestamp: '2022-08-09T15:29:54.388Z',
codimd_1    |   [Symbol(level)]: 'error',
codimd_1    |   [Symbol(message)]:
codimd_1    |    '2022-08-09T15:29:54.388Z error: \tCommand failed: /home/hackmd/app/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs /home/hackmd/app/node_modules/markdown-pdf/phantom/render.js /tmp/tmp-23T217YkHOtWhW.html /tmp/tmp-238Mg00jNGpimx.pdf /home/hackmd/app /home/hackmd/app/node_modules/markdown-pdf/runnings.js /home/hackmd/app/node_modules/markdown-pdf/css/pdf.css /home/hackmd/app/node_modules/highlight.js/styles/github-gist.css A4 portrait 2cm 0 10000\nThis application failed to start because it could not find or load the Qt platform plugin "offscreen".\n\nAvailable platform plugins are: phantom.\n\nReinstalling the application may fix this problem.\nPhantomJS has crashed. Please read the bug reporting guide at\n<http://phantomjs.org/bug-reporting.html> and file a bug report.\n' }
codimd_1    | 2022-08-09T15:29:54.391Z error:   Process will exit now.
codimd_codimd_1 exited with code 1

I use the latest docker image, hackmdio/hackmd:2.4.2-cjk.

Thanks for your help.

kalon33 avatar Aug 09 '22 15:08 kalon33

It is happening to our deployment as well..

mic4ael avatar Aug 30 '22 14:08 mic4ael

Hi @kalon33 , @mic4ael Thanks for report the issue.

We'll release 2.4.3 soon to resolve this issue.

The quick way to fix this bug is to set QT_QPA_PLATFORM to empty.

version: "3"
services:
  database:
    image: postgres:11.6-alpine
    environment:
      - POSTGRES_USER=codimd
      - POSTGRES_PASSWORD=change_password
      - POSTGRES_DB=codimd
    volumes:
      - "database-data:/var/lib/postgresql/data"
    restart: always
  codimd:
    # you can use image or custom build below,
    # if you need CJK character with exported PDF files,
    # please change the image tag with `cjk` postfix version
    image: hackmdio/hackmd:2.4.2-cjk
    environment:
      - CMD_DOMAIN=192.168.5.229
      - CMD_URL_ADDPORT=true
      - CMD_DB_URL=postgres://codimd:change_password@database/codimd
      - CMD_USECDN=false
      - QT_QPA_PLATFORM=
    depends_on:
      - database
    ports:
      - "3000:3000"
    volumes:
      - upload-data:/home/hackmd/app/public/uploads
    restart: always
volumes:
  database-data: {}
  upload-data: {}

a60814billy avatar Sep 04 '22 04:09 a60814billy

Hi @kalon33 , @mic4ael Thanks for report the issue.

We'll release 2.4.3 soon to resolve this issue.

The quick way to fix this bug is to set QT_QPA_PLATFORM to empty.

version: "3"
services:
  database:
    image: postgres:11.6-alpine
    environment:
      - POSTGRES_USER=codimd
      - POSTGRES_PASSWORD=change_password
      - POSTGRES_DB=codimd
    volumes:
      - "database-data:/var/lib/postgresql/data"
    restart: always
  codimd:
    # you can use image or custom build below,
    # if you need CJK character with exported PDF files,
    # please change the image tag with `cjk` postfix version
    image: hackmdio/hackmd:2.4.2-cjk
    environment:
      - CMD_DOMAIN=192.168.5.229
      - CMD_URL_ADDPORT=true
      - CMD_DB_URL=postgres://codimd:change_password@database/codimd
      - CMD_USECDN=false
      - QT_QPA_PLATFORM=
    depends_on:
      - database
    ports:
      - "3000:3000"
    volumes:
      - upload-data:/home/hackmd/app/public/uploads
    restart: always
volumes:
  database-data: {}
  upload-data: {}

Thanks for the workaround idea!

mic4ael avatar Sep 05 '22 05:09 mic4ael

@a60814billy @mic4ael Hi,

It is working and I now have a PDF document generated. It that expected that checkboxes, HTML code, etc... are not interpreted in the final PDF document and appear as raw code?

Thanks for your help.

kalon33 avatar Sep 05 '22 12:09 kalon33

We'll release 2.4.3 soon to resolve this issue.

Are you still planning on releasing 2.4.3 anytime soon?

2001db8 avatar Aug 02 '23 14:08 2001db8

thanks for workaround? but either links not working nor [TOC] not showed

AVert avatar Sep 07 '23 17:09 AVert

Interesting, I'm hitting the error even with the workaround in place.

notes-658c5d9fcf-z5bnm notes 2024-05-04T17:20:36.146Z info: 	deserializeUser: cd4cc5c8-bf2e-413a-87bf-a152c39c7a42
notes-658c5d9fcf-z5bnm notes 2024-05-04T17:20:36.734Z error: 	uncaughtException: Command failed: /home/hackmd/app/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs /home/hackmd/app/node_modules/markdown-pdf/phantom/render.js /tmp/tmp-48FH8o2fzHvXos.html /tmp/tmp-485TIXwCTJj7JH.pdf /home/hackmd/app /home/hackmd/app/node_modules/markdown-pdf/runnings.js /home/hackmd/app/node_modules/markdown-pdf/css/pdf.css /home/hackmd/app/node_modules/highlight.js/styles/github-gist.css A4 portrait 2cm 0 10000
notes-658c5d9fcf-z5bnm notes Auto configuration failed
notes-658c5d9fcf-z5bnm notes 140030312836736:error:25066067:DSO support routines:DLFCN_LOAD:could not load the shared library:dso_dlfcn.c:185:filename(libssl_conf.so): libssl_conf.so: cannot open shared object file: No such file or directory
notes-658c5d9fcf-z5bnm notes 140030312836736:error:25070067:DSO support routines:DSO_load:could not load the shared library:dso_lib.c:244:
notes-658c5d9fcf-z5bnm notes 140030312836736:error:0E07506E:configuration file routines:MODULE_LOAD_DSO:error loading dso:conf_mod.c:285:module=ssl_conf, path=ssl_conf
notes-658c5d9fcf-z5bnm notes 140030312836736:error:0E076071:configuration file routines:MODULE_RUN:unknown module name:conf_mod.c:222:module=ssl_conf
notes-658c5d9fcf-z5bnm notes 
notes-658c5d9fcf-z5bnm notes Error: Command failed: /home/hackmd/app/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs /home/hackmd/app/node_modules/markdown-pdf/phantom/render.js /tmp/tmp-48FH8o2fzHvXos.html /tmp/tmp-485TIXwCTJj7JH.pdf /home/hackmd/app /home/hackmd/app/node_modules/markdown-pdf/runnings.js /home/hackmd/app/node_modules/markdown-pdf/css/pdf.css /home/hackmd/app/node_modules/highlight.js/styles/github-gist.css A4 portrait 2cm 0 10000
notes-658c5d9fcf-z5bnm notes Auto configuration failed
notes-658c5d9fcf-z5bnm notes 140030312836736:error:25066067:DSO support routines:DLFCN_LOAD:could not load the shared library:dso_dlfcn.c:185:filename(libssl_conf.so): libssl_conf.so: cannot open shared object file: No such file or directory
notes-658c5d9fcf-z5bnm notes 140030312836736:error:25070067:DSO support routines:DSO_load:could not load the shared library:dso_lib.c:244:
notes-658c5d9fcf-z5bnm notes 140030312836736:error:0E07506E:configuration file routines:MODULE_LOAD_DSO:error loading dso:conf_mod.c:285:module=ssl_conf, path=ssl_conf
notes-658c5d9fcf-z5bnm notes 140030312836736:error:0E076071:configuration file routines:MODULE_RUN:unknown module name:conf_mod.c:222:module=ssl_conf
notes-658c5d9fcf-z5bnm notes 
notes-658c5d9fcf-z5bnm notes     at ChildProcess.exithandler (node:child_process:402:12)
notes-658c5d9fcf-z5bnm notes     at ChildProcess.emit (node:events:513:28)
notes-658c5d9fcf-z5bnm notes     at maybeClose (node:internal/child_process:1100:16)
notes-658c5d9fcf-z5bnm notes     at Process.ChildProcess._handle.onexit (node:internal/child_process:304:5)
notes-658c5d9fcf-z5bnm notes 2024-05-04T17:20:36.735Z error: 	An uncaught exception has occured.
notes-658c5d9fcf-z5bnm notes 2024-05-04T17:20:36.735Z error: 	Command failed: /home/hackmd/app/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs /home/hackmd/app/node_modules/markdown-pdf/phantom/render.js /tmp/tmp-48FH8o2fzHvXos.html /tmp/tmp-485TIXwCTJj7JH.pdf /home/hackmd/app /home/hackmd/app/node_modules/markdown-pdf/runnings.js /home/hackmd/app/node_modules/markdown-pdf/css/pdf.css /home/hackmd/app/node_modules/highlight.js/styles/github-gist.css A4 portrait 2cm 0 10000
notes-658c5d9fcf-z5bnm notes Auto configuration failed
notes-658c5d9fcf-z5bnm notes 140030312836736:error:25066067:DSO support routines:DLFCN_LOAD:could not load the shared library:dso_dlfcn.c:185:filename(libssl_conf.so): libssl_conf.so: cannot open shared object file: No such file or directory
notes-658c5d9fcf-z5bnm notes 140030312836736:error:25070067:DSO support routines:DSO_load:could not load the shared library:dso_lib.c:244:
notes-658c5d9fcf-z5bnm notes 140030312836736:error:0E07506E:configuration file routines:MODULE_LOAD_DSO:error loading dso:conf_mod.c:285:module=ssl_conf, path=ssl_conf
notes-658c5d9fcf-z5bnm notes 140030312836736:error:0E076071:configuration file routines:MODULE_RUN:unknown module name:conf_mod.c:222:module=ssl_conf
notes-658c5d9fcf-z5bnm notes 
notes-658c5d9fcf-z5bnm notes Error: Command failed: /home/hackmd/app/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs /home/hackmd/app/node_modules/markdown-pdf/phantom/render.js /tmp/tmp-48FH8o2fzHvXos.html /tmp/tmp-485TIXwCTJj7JH.pdf /home/hackmd/app /home/hackmd/app/node_modules/markdown-pdf/runnings.js /home/hackmd/app/node_modules/markdown-pdf/css/pdf.css /home/hackmd/app/node_modules/highlight.js/styles/github-gist.css A4 portrait 2cm 0 10000
notes-658c5d9fcf-z5bnm notes Auto configuration failed
notes-658c5d9fcf-z5bnm notes 2024-05-04T17:20:36.745Z error: 	Process will exit now.
notes-658c5d9fcf-z5bnm notes 140030312836736:error:25066067:DSO support routines:DLFCN_LOAD:could not load the shared library:dso_dlfcn.c:185:filename(libssl_conf.so): libssl_conf.so: cannot open shared object file: No such file or directory
notes-658c5d9fcf-z5bnm notes 140030312836736:error:25070067:DSO support routines:DSO_load:could not load the shared library:dso_lib.c:244:
notes-658c5d9fcf-z5bnm notes 140030312836736:error:0E07506E:configuration file routines:MODULE_LOAD_DSO:error loading dso:conf_mod.c:285:module=ssl_conf, path=ssl_conf
notes-658c5d9fcf-z5bnm notes 140030312836736:error:0E076071:configuration file routines:MODULE_RUN:unknown module name:conf_mod.c:222:module=ssl_conf
notes-658c5d9fcf-z5bnm notes 
notes-658c5d9fcf-z5bnm notes     at ChildProcess.exithandler (node:child_process:402:12)
notes-658c5d9fcf-z5bnm notes     at ChildProcess.emit (node:events:513:28)
notes-658c5d9fcf-z5bnm notes     at maybeClose (node:internal/child_process:1100:16)
notes-658c5d9fcf-z5bnm notes     at Process.ChildProcess._handle.onexit (node:internal/child_process:304:5) {
notes-658c5d9fcf-z5bnm notes   code: 1,
notes-658c5d9fcf-z5bnm notes   killed: false,
notes-658c5d9fcf-z5bnm notes   signal: null,
notes-658c5d9fcf-z5bnm notes   cmd: '/home/hackmd/app/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs /home/hackmd/app/node_modules/markdown-pdf/phantom/render.js /tmp/tmp-48FH8o2fzHvXos.html /tmp/tmp-485TIXwCTJj7JH.pdf /home/hackmd/app /home/hackmd/app/node_modules/markdown-pdf/runnings.js /home/hackmd/app/node_modules/markdown-pdf/css/pdf.css /home/hackmd/app/node_modules/highlight.js/styles/github-gist.css A4 portrait 2cm 0 10000',
notes-658c5d9fcf-z5bnm notes   level: 'error',
notes-658c5d9fcf-z5bnm notes   timestamp: '2024-05-04T17:20:36.735Z',
notes-658c5d9fcf-z5bnm notes   [Symbol(level)]: 'error',
notes-658c5d9fcf-z5bnm notes   [Symbol(message)]: '2024-05-04T17:20:36.735Z error: \tCommand failed: /home/hackmd/app/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs /home/hackmd/app/node_modules/markdown-pdf/phantom/render.js /tmp/tmp-48FH8o2fzHvXos.html /tmp/tmp-485TIXwCTJj7JH.pdf /home/hackmd/app /home/hackmd/app/node_modules/markdown-pdf/runnings.js /home/hackmd/app/node_modules/markdown-pdf/css/pdf.css /home/hackmd/app/node_modules/highlight.js/styles/github-gist.css A4 portrait 2cm 0 10000\n' +
notes-658c5d9fcf-z5bnm notes     'Auto configuration failed\n' +
notes-658c5d9fcf-z5bnm notes     '140030312836736:error:25066067:DSO support routines:DLFCN_LOAD:could not load the shared library:dso_dlfcn.c:185:filename(libssl_conf.so): libssl_conf.so: cannot open shared object file: No such file or directory\n' +
notes-658c5d9fcf-z5bnm notes     '140030312836736:error:25070067:DSO support routines:DSO_load:could not load the shared library:dso_lib.c:244:\n' +
notes-658c5d9fcf-z5bnm notes     '140030312836736:error:0E07506E:configuration file routines:MODULE_LOAD_DSO:error loading dso:conf_mod.c:285:module=ssl_conf, path=ssl_conf\n' +
notes-658c5d9fcf-z5bnm notes     '140030312836736:error:0E076071:configuration file routines:MODULE_RUN:unknown module name:conf_mod.c:222:module=ssl_conf\n'
notes-658c5d9fcf-z5bnm notes }
❯ kubectl print-env pod notes-658c5d9fcf-z5bnm | grep QT
QT_QPA_PLATFORM=


❯ kubectl images -n notes
[Summary]: 1 namespaces, 1 pods, 4 containers and 3 different images
+------------------------+-------------------------+--------------------------------------+
|          Pod           |        Container        |                Image                 |
+------------------------+-------------------------+--------------------------------------+
| notes-658c5d9fcf-z5bnm | notes                   | docker.io/hackmdio/hackmd:2.5.3      |
+                        +-------------------------+--------------------------------------+
|                        | istio-proxy             | docker.io/istio/proxyv2:1.21.2       |
+                        +-------------------------+--------------------------------------+
|                        | (init) copy-vault-env   | ghcr.io/banzaicloud/vault-env:1.19.0 |
+                        +-------------------------+--------------------------------------+
|                        | (init) istio-validation | docker.io/istio/proxyv2:1.21.2       |
+------------------------+-------------------------+--------------------------------------+

tchellomello avatar May 04 '24 17:05 tchellomello