ggrossetie / asciidoctor-web-pdf

Convert AsciiDoc documents to PDF using web technologies
https://asciidoctor.org
MIT License
445 stars 92 forks source link

Timeout error when converting a document #531

Open vishalkrsinha opened 3 years ago

vishalkrsinha commented 3 years ago

Using below Azure-Devops build pipeline script to install asciidoctor-web-pdf on 'ubuntu-latest'.

stages:
- stage: __default
  jobs:
  - job: UbuntuBuild
    timeoutInMinutes: 90
    pool:
      vmImage: 'ubuntu-latest'

    # Always clean workspace
    workspace:
      clean: all
    steps:
      - task: PowerShell@2
        displayName: Installing asciidoctor-web-pdf
        inputs:
          targetType: 'inline'
          script: |           
            npm init -y         
            npm i @asciidoctor/core asciidoctor-pdf --save-dev
            npx asciidoctor-web-pdf --version
            npm i -g @asciidoctor/core asciidoctor-pdf
            asciidoctor-web-pdf --version

And getting below installation step result log.

2021-07-26T09:39:57.6770290Z ##[section]Starting: Installing asciidoctor-web-pdf
2021-07-26T09:39:57.6780779Z ==============================================================================
2021-07-26T09:39:57.6781220Z Task         : PowerShell
2021-07-26T09:39:57.6781576Z Description  : Run a PowerShell script on Linux, macOS, or Windows
2021-07-26T09:39:57.6781897Z Version      : 2.186.0
2021-07-26T09:39:57.6782198Z Author       : Microsoft Corporation
2021-07-26T09:39:57.6782599Z Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/powershell
2021-07-26T09:39:57.6783056Z ==============================================================================
2021-07-26T09:39:58.0326311Z Generating script.
2021-07-26T09:39:58.0371146Z ========================== Starting Command Output ===========================
2021-07-26T09:39:58.0379176Z [command]/usr/bin/pwsh -NoLogo -NoProfile -NonInteractive -Command . '/home/vsts/work/_temp/5227e0e1-6b28-4150-bd43-d2c47511d99b.ps1'
2021-07-26T09:40:02.9829695Z Wrote to /home/vsts/work/1/s/package.json:
2021-07-26T09:40:02.9830584Z 
2021-07-26T09:40:02.9831143Z {
2021-07-26T09:40:02.9831683Z   "name": "s",
2021-07-26T09:40:02.9832241Z   "version": "1.0.0",
2021-07-26T09:40:02.9833614Z   "description": "This is the new home for the K-Spice documentation",
2021-07-26T09:40:02.9834353Z   "main": "index.js",
2021-07-26T09:40:02.9834917Z   "scripts": {
2021-07-26T09:40:02.9835565Z     "test": "echo \"Error: no test specified\" && exit 1"
2021-07-26T09:40:02.9836176Z   },
2021-07-26T09:40:02.9836698Z   "repository": {
2021-07-26T09:40:02.9837261Z     "type": "git",
2021-07-26T09:40:02.9838171Z     "url": "https://kognifai.visualstudio.com/K-Spice/_git/kspice-docs"
2021-07-26T09:40:02.9839147Z   },
2021-07-26T09:40:02.9839687Z   "keywords": [],
2021-07-26T09:40:02.9840242Z   "author": "",
2021-07-26T09:40:02.9840987Z   "license": "ISC"
2021-07-26T09:40:02.9844137Z }
2021-07-26T09:40:02.9844584Z 
2021-07-26T09:40:02.9845183Z 
2021-07-26T09:40:15.8249538Z npm WARN deprecated @babel/polyfill@7.12.1: 🚨 This package has been deprecated in favor of separate inclusion of a polyfill and regenerator-runtime (when needed). See the @babel/polyfill docs (https://babeljs.io/docs/en/babel-polyfill) for more information.
2021-07-26T09:40:16.6701280Z npm WARN deprecated core-js@2.6.12: core-js@<3.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js.
2021-07-26T09:40:22.6013551Z 
2021-07-26T09:40:22.6014968Z > puppeteer@7.1.0 install /home/vsts/work/1/s/node_modules/puppeteer
2021-07-26T09:40:22.6015683Z > node install.js
2021-07-26T09:40:22.6016078Z 
2021-07-26T09:40:26.9864361Z 
2021-07-26T09:40:33.6363320Z Chromium (848005) downloaded to /home/vsts/work/1/s/node_modules/puppeteer/.local-chromium/linux-848005
2021-07-26T09:40:33.6551771Z 
2021-07-26T09:40:33.6553894Z > @fortawesome/fontawesome-common-types@0.2.35 postinstall /home/vsts/work/1/s/node_modules/@fortawesome/fontawesome-common-types
2021-07-26T09:40:33.6554817Z > node attribution.js
2021-07-26T09:40:33.6555207Z 
2021-07-26T09:40:33.7018180Z Font Awesome Free 0.2.35 by @fontawesome - https://fontawesome.com
2021-07-26T09:40:33.7019704Z License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
2021-07-26T09:40:33.7020281Z 
2021-07-26T09:40:33.7141006Z 
2021-07-26T09:40:33.7142858Z > core-js@2.6.12 postinstall /home/vsts/work/1/s/node_modules/core-js
2021-07-26T09:40:33.7143602Z > node -e "try{require('./postinstall')}catch(e){}"
2021-07-26T09:40:33.7143868Z 
2021-07-26T09:40:33.7645871Z Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library!
2021-07-26T09:40:33.7646798Z 
2021-07-26T09:40:33.7648712Z The project needs your help! Please consider supporting of core-js on Open Collective or Patreon: 
2021-07-26T09:40:33.7650324Z > https://opencollective.com/core-js 
2021-07-26T09:40:33.7651220Z > https://www.patreon.com/zloirock 
2021-07-26T09:40:33.7651573Z 
2021-07-26T09:40:33.7652581Z Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -)
2021-07-26T09:40:33.7653039Z 
2021-07-26T09:40:33.7825928Z 
2021-07-26T09:40:33.7827829Z > @fortawesome/fontawesome-svg-core@1.2.34 postinstall /home/vsts/work/1/s/node_modules/@fortawesome/fontawesome-svg-core
2021-07-26T09:40:33.7828649Z > node attribution.js
2021-07-26T09:40:33.7829023Z 
2021-07-26T09:40:33.8344827Z Font Awesome Free 1.2.34 by @fontawesome - https://fontawesome.com
2021-07-26T09:40:33.8346532Z License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
2021-07-26T09:40:33.8347142Z 
2021-07-26T09:40:33.8457713Z 
2021-07-26T09:40:33.8459757Z > @fortawesome/free-brands-svg-icons@5.15.2 postinstall /home/vsts/work/1/s/node_modules/@fortawesome/free-brands-svg-icons
2021-07-26T09:40:33.8460578Z > node attribution.js
2021-07-26T09:40:33.8460797Z 
2021-07-26T09:40:33.9006260Z Font Awesome Free 5.15.2 by @fontawesome - https://fontawesome.com
2021-07-26T09:40:33.9007806Z License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
2021-07-26T09:40:33.9008439Z 
2021-07-26T09:40:33.9118984Z 
2021-07-26T09:40:33.9121097Z > @fortawesome/free-regular-svg-icons@5.15.2 postinstall /home/vsts/work/1/s/node_modules/@fortawesome/free-regular-svg-icons
2021-07-26T09:40:33.9121851Z > node attribution.js
2021-07-26T09:40:33.9122316Z 
2021-07-26T09:40:33.9758169Z Font Awesome Free 5.15.2 by @fontawesome - https://fontawesome.com
2021-07-26T09:40:33.9759367Z License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
2021-07-26T09:40:33.9759712Z 
2021-07-26T09:40:33.9852332Z 
2021-07-26T09:40:33.9853921Z > @fortawesome/free-solid-svg-icons@5.15.2 postinstall /home/vsts/work/1/s/node_modules/@fortawesome/free-solid-svg-icons
2021-07-26T09:40:33.9854616Z > node attribution.js
2021-07-26T09:40:33.9854837Z 
2021-07-26T09:40:34.0357967Z Font Awesome Free 5.15.2 by @fontawesome - https://fontawesome.com
2021-07-26T09:40:34.0359526Z License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
2021-07-26T09:40:34.0360108Z 
2021-07-26T09:40:34.1462288Z npm notice created a lockfile as package-lock.json. You should commit this file.
2021-07-26T09:40:34.1528144Z npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.3.1 (node_modules/chokidar/node_modules/fsevents):
2021-07-26T09:40:34.1529552Z npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
2021-07-26T09:40:34.1531058Z 
2021-07-26T09:40:34.1544271Z + @asciidoctor/core@2.2.4
2021-07-26T09:40:34.1545553Z + asciidoctor-pdf@1.0.0-alpha.12
2021-07-26T09:40:34.1546339Z added 135 packages from 188 contributors and audited 136 packages in 28.867s
2021-07-26T09:40:34.2034563Z 
2021-07-26T09:40:34.2035890Z 10 packages are looking for funding
2021-07-26T09:40:34.2036660Z   run `npm fund` for details
2021-07-26T09:40:34.2037074Z 
2021-07-26T09:40:34.2038618Z found 0 vulnerabilities
2021-07-26T09:40:34.2039071Z 
2021-07-26T09:40:34.8374642Z Asciidoctor Web PDF 1.0.0-alpha.12 using Asciidoctor.js 2.2.4 (Asciidoctor 2.0.15) [https://asciidoctor.org]
2021-07-26T09:40:34.8377903Z Runtime Environment (node v14.17.3 on linux)
2021-07-26T09:40:34.8378733Z CLI version 3.4.0
2021-07-26T09:40:36.5762674Z npm WARN deprecated @babel/polyfill@7.12.1: 🚨 This package has been deprecated in favor of separate inclusion of a polyfill and regenerator-runtime (when needed). See the @babel/polyfill docs (https://babeljs.io/docs/en/babel-polyfill) for more information.
2021-07-26T09:40:36.6230145Z npm WARN deprecated core-js@2.6.12: core-js@<3.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js.
2021-07-26T09:40:41.4066819Z /usr/local/bin/asciidoctor-pdf -> /usr/local/lib/node_modules/asciidoctor-pdf/bin/asciidoctor-pdf
2021-07-26T09:40:41.4068487Z /usr/local/bin/asciidoctor-web-pdf -> /usr/local/lib/node_modules/asciidoctor-pdf/bin/asciidoctor-web-pdf
2021-07-26T09:40:41.4304651Z 
2021-07-26T09:40:41.4306660Z > puppeteer@7.1.0 install /usr/local/lib/node_modules/asciidoctor-pdf/node_modules/puppeteer
2021-07-26T09:40:41.4307503Z > node install.js
2021-07-26T09:40:41.4307951Z 
2021-07-26T09:40:42.6878919Z 
2021-07-26T09:40:49.2536786Z Chromium (848005) downloaded to /usr/local/lib/node_modules/asciidoctor-pdf/node_modules/puppeteer/.local-chromium/linux-848005
2021-07-26T09:40:49.2715437Z 
2021-07-26T09:40:49.2717667Z > @fortawesome/fontawesome-common-types@0.2.35 postinstall /usr/local/lib/node_modules/asciidoctor-pdf/node_modules/@fortawesome/fontawesome-common-types
2021-07-26T09:40:49.2718419Z > node attribution.js
2021-07-26T09:40:49.2718591Z 
2021-07-26T09:40:49.3202848Z Font Awesome Free 0.2.35 by @fontawesome - https://fontawesome.com
2021-07-26T09:40:49.3206605Z License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
2021-07-26T09:40:49.3207320Z 
2021-07-26T09:40:49.3295125Z 
2021-07-26T09:40:49.3297592Z > core-js@2.6.12 postinstall /usr/local/lib/node_modules/asciidoctor-pdf/node_modules/core-js
2021-07-26T09:40:49.3298436Z > node -e "try{require('./postinstall')}catch(e){}"
2021-07-26T09:40:49.3298946Z 
2021-07-26T09:40:49.4029244Z 
2021-07-26T09:40:49.4031134Z > @fortawesome/fontawesome-svg-core@1.2.34 postinstall /usr/local/lib/node_modules/asciidoctor-pdf/node_modules/@fortawesome/fontawesome-svg-core
2021-07-26T09:40:49.4031716Z > node attribution.js
2021-07-26T09:40:49.4031938Z 
2021-07-26T09:40:49.4709883Z Font Awesome Free 1.2.34 by @fontawesome - https://fontawesome.com
2021-07-26T09:40:49.4712045Z License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
2021-07-26T09:40:49.4712919Z 
2021-07-26T09:40:49.4787241Z 
2021-07-26T09:40:49.4789773Z > @fortawesome/free-brands-svg-icons@5.15.2 postinstall /usr/local/lib/node_modules/asciidoctor-pdf/node_modules/@fortawesome/free-brands-svg-icons
2021-07-26T09:40:49.4792370Z > node attribution.js
2021-07-26T09:40:49.4792771Z 
2021-07-26T09:40:49.5291859Z Font Awesome Free 5.15.2 by @fontawesome - https://fontawesome.com
2021-07-26T09:40:49.5293632Z License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
2021-07-26T09:40:49.5294233Z 
2021-07-26T09:40:49.5360016Z 
2021-07-26T09:40:49.5362361Z > @fortawesome/free-regular-svg-icons@5.15.2 postinstall /usr/local/lib/node_modules/asciidoctor-pdf/node_modules/@fortawesome/free-regular-svg-icons
2021-07-26T09:40:49.5363290Z > node attribution.js
2021-07-26T09:40:49.5363748Z 
2021-07-26T09:40:49.5831435Z Font Awesome Free 5.15.2 by @fontawesome - https://fontawesome.com
2021-07-26T09:40:49.5833127Z License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
2021-07-26T09:40:49.5833781Z 
2021-07-26T09:40:49.5946079Z 
2021-07-26T09:40:49.5948034Z > @fortawesome/free-solid-svg-icons@5.15.2 postinstall /usr/local/lib/node_modules/asciidoctor-pdf/node_modules/@fortawesome/free-solid-svg-icons
2021-07-26T09:40:49.5948996Z > node attribution.js
2021-07-26T09:40:49.5949369Z 
2021-07-26T09:40:49.6428672Z Font Awesome Free 5.15.2 by @fontawesome - https://fontawesome.com
2021-07-26T09:40:49.6429784Z License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
2021-07-26T09:40:49.6430127Z 
2021-07-26T09:40:49.6590534Z npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.3.1 (node_modules/asciidoctor-pdf/node_modules/chokidar/node_modules/fsevents):
2021-07-26T09:40:49.6593140Z npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
2021-07-26T09:40:49.6593927Z 
2021-07-26T09:40:49.6602575Z + @asciidoctor/core@2.2.4
2021-07-26T09:40:49.6603585Z + asciidoctor-pdf@1.0.0-alpha.12
2021-07-26T09:40:49.6604283Z added 146 packages from 188 contributors in 14.392s
2021-07-26T09:40:50.2515900Z Asciidoctor Web PDF 1.0.0-alpha.12 using Asciidoctor.js 2.2.4 (Asciidoctor 2.0.15) [https://asciidoctor.org]
2021-07-26T09:40:50.2517139Z Runtime Environment (node v14.17.3 on linux)
2021-07-26T09:40:50.2517831Z CLI version 3.4.0
2021-07-26T09:40:50.7139667Z ##[section]Finishing: Installing asciidoctor-web-pdf

But while using 'asciidoctor-web-pdf' command like below to convert pdf file with latex equations: asciidoctor-web-pdf $src -o $dest -a stem

get below error message:

2021-07-26T10:00:54.1568044Z Unable to generate the PDF - Error: TimeoutError: Navigation timeout of 30000 ms exceeded
2021-07-26T10:00:54.1571362Z > TIP: You can configure the timeout in milliseconds using PUPPETEER_DEFAULT_TIMEOUT, PUPPETEER_NAVIGATION_TIMEOUT or PUPPETEER_RENDERING_TIMEOUT environment variables.
2021-07-26T10:00:54.1981607Z Module pdf file: /home/vsts/work/1/a/Explorer/Resources/Modules/MPowerManagementSystem/help/ElectricCircuitBreaker.pdf

Any suggestion how to handle such errors.

ggrossetie commented 3 years ago

Usually, when it takes more than 30 seconds the reasons is that Paged.js cannot fit the content on a page and loops endlessly.

Any suggestion how to handle such errors.

You should try to reproduce this issue locally. You can also use the --preview option to open the document in a local browser to troubleshoot (i.e., open DevTools).

vishalkrsinha commented 3 years ago

Usually, when it takes more than 30 seconds the reasons is that Paged.js cannot fit the content on a page and loops endlessly.

Any suggestion how to handle such errors.

You should try to reproduce this issue locally. You can also use the --preview option to open the document in a local browser to troubleshoot (i.e., open DevTools).

Tried running it locally with the same timeout message as a result. Attached is the screenshot for the same. TimeoutIssue

Not sure, what/how can I troubleshoot the issue?

PS:

  1. Tried using --preview option too but it simply opens it in a local browser.
  2. Why instead of generating a pdf file, it's generating an HTML file?
ggrossetie commented 3 years ago

Tried using --preview option too but it simply opens it in a local browser.

Yes it should open a local browser with your document. You can then open the DevTools and check the console (if there's any error). You can also inspect the page to make sure that all the content is visible.

Why instead of generating a pdf file, it's generating an HTML file?

Because asciidoctor-web-pdf is using the browser (i.e., a web page) to generate PDF. So it generates an HTML page and then creates a PDF from it.

ggrossetie commented 3 years ago

Is it possible to share this document? I can try to troubleshoot on my machine.

vishalkrsinha commented 3 years ago

Is it possible to share this document? I can try to troubleshoot on my machine.

I investigated it further locally & found the root cause for one of my document. Root cause: column widths in a table were not correct. Solution: Changed column widths from fixed width size to 'auto' as below:

Before:

[cols="13,19,18,6,8,8,8,10,10"]
|===
|Trip/open action
|Test Criterion 1
...

Auto-widths:

[cols="auto,auto,auto,auto,auto,auto,auto,auto,auto"]
|===
|Trip/open action
|Test Criterion 1

Will check the same (tomorrow morning) for other documents having Timeout issue & will further update here. Thanks.

vishalkrsinha commented 3 years ago

Is it possible to share this document? I can try to troubleshoot on my machine.

I have one more document with same timeout issue. But, I couldn't resolve that. Attaching a minimal script that I could prepare for your reference to test & figure out the problem. I guess, issue lies in starting line no 79 (!===). test.txt

Kindly rename the file to .adoc while testing. Thank you in advance.

ggrossetie commented 3 years ago

I have one more document with same timeout issue. But, I couldn't resolve that. Attaching a minimal script that I could prepare for your reference to test & figure out the problem. I guess, issue lies in starting line no 79 (!===).

Paged.js goes into an infinite loop probably because the table contains nested tables (i.e., it contains tables inside table cells).

Paged.js chunker has quite a few issues with tables. The good news is that they are planning on fixing these issues for Paged.js 1.0: https://gitlab.pagedmedia.org/tools/pagedjs/issues/332

The chunker is quite complex and I cannot tell you what exactly you need to change. Using auto width can certainly helps since it makes it easier to fit the content on the page (less constraints).

ggrossetie commented 3 years ago

[cols="auto,auto,auto,auto,auto,auto,auto,auto,auto"]

I don't think this is the right syntax, you should use [cols="9"]. This definition means that you have 9 columns (and since we don't explicitly specify width, column will be adjusted automatically).

If I remove the sixth row (headEfficiencyOption) then I get a PDF:

I believe that the nested table is too large and Paged.js cannot figure out how to fit it into the page (looping indefinitely).