marp-team / marp-cli

A CLI interface for Marp and Marpit based converters
MIT License
1.92k stars 108 forks source link

Strange TimeoutError from Puppeteer\common\util.js #588

Closed Vikramsingh-karnot closed 2 months ago

Vikramsingh-karnot commented 2 months ago

I have created a azure pipeline & I'm using marp cli on to convert md to pdf. But facing timeout error from util.js. These I'm getting in both linux agent as well as windows agent. image I have also setup an chrome path. (tried with both chrome path & edge path.) But nothing worked. Trying to Resolve it from last 1 week but no luck. @yhatt Please help. Below is my pipeline powershell script.

  steps:
  - task: PowerShell@2
    inputs:
      targetType: 'inline'
      script: |

        $env:CHROME_PATH="C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe"
        New-Item -Path ".\$(pdf_output)" -ItemType "Directory"
        marp --html --allow-local-files --theme $(Build.SourcesDirectory)/Stylesheets/marp-theme.css $(Build.SourcesDirectory)/slides.md --pdf -o $(Build.SourcesDirectory)/$(pdf_output)/slides.pdf
yhatt commented 2 months ago

https://github.com/orgs/marp-team/discussions/225

Vikramsingh-karnot commented 2 months ago

set PUPPETEER_TIMEOUT=80000 @yhatt I added it but I didn't worked same issue. And their is no resource constraint because I'm using a dedicated agent with 2vcpus & 8 GB of RAM.

yhatt commented 2 months ago

Try to disable timeout through PUPPETEER_TIMEOUT=0. And setting DEBUG=* env would help to get Puppeteer logs while converting.

Vikramsingh-karnot commented 2 months ago

After setting up above two env's it did not printed any special logs same error i got @yhatt . image Modified Pipeline task

  steps:
  - task: PowerShell@2
    inputs:
      targetType: 'inline'
      script: |

        # Define the new path to add
        $newPath = 'C:\Users\docascode\AppData\Roaming\npm;C:\Program Files\nodejs;C:\Program Files\Google\Chrome\Application\;C:\Program Files (x86)\Microsoft\Edge\Application\'
        $currentPath = $env:Path
        $env:Path = "$currentPath;$newPath"
        $env:CHROME_PATH="C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe"
        Write-Host $env:Path 
        npm install -g @marp-team/marp-cli
        marp --version
        New-Item -Path ".\$(pdf_output)" -ItemType "Directory"
        set PUPPETEER_TIMEOUT=0
        set DEBUG=*
        marp --html --allow-local-files --theme $(Build.SourcesDirectory)/Stylesheets/marp-theme.css $(Build.SourcesDirectory)/slides.md --pdf -o $(Build.SourcesDirectory)/$(pdf_output)/slides.pdf

      displayName: 'Installing Required Packages'
yhatt commented 2 months ago

If you are using PowerShell, you should use $env:PUPPETEER_TIMEOUT=0 and $env:DEBUG="*" instead of set (for cmd).

Vikramsingh-karnot commented 2 months ago

Yes, It worked got detail logs! But it got failed in the end. @yhatt

2024-09-10T10:20:04.270Z puppeteer:browsers:launcher Launched 8620
2024-09-10T10:20:04.922Z puppeteer:protocol:SEND ► [
  '{"method":"Target.setDiscoverTargets","params":{"discover":true,"filter":[{}]},"id":1}'
]
2024-09-10T10:20:04.991Z puppeteer:protocol:RECV ◀ [
  '{"method":"Target.targetCreated","params":{"targetInfo":{"targetId":"********************","type":"tab","title":"","url":"about:blank","attached":false,"canAccessOpener":false,"browserContextId":"**************************","pid":0}}}'
]

2024-09-10T10:23:06.599Z puppeteer:protocol:RECV ◀ [
  '{"method":"Target.targetDestroyed","params":{"targetId":"****************"}}'
]
2024-09-10T10:23:06.599Z puppeteer:protocol:RECV ◀ [
  '{"method":"Target.targetInfoChanged","params":{"targetInfo":{"targetId":"******************","type":"tab","title":"","url":"","attached":false,"canAccessOpener":false,"browserContextId":"*********************","pid":0}}}'
]
2024-09-10T10:23:06.599Z puppeteer:protocol:RECV ◀ [
  '{"method":"Target.detachedFromTarget","params":{"sessionId":"**********************","targetId":"******************"}}'
]
2024-09-10T10:23:06.600Z puppeteer:protocol:RECV ◀ [
  '{"method":"Target.targetDestroyed","params":{"targetId":"***********"}}'
]
2024-09-10T10:23:06.808Z puppeteer:browsers:launcher Browser process 8620 onExit
C:\Users\docascode\AppData\Roaming\npm\node_modules\@marp-team\marp-cli\node_modules\puppeteer-core\lib\cjs\puppeteer\common\CallbackRegistry.js:96
    #error = new Errors_js_1.ProtocolError();
             ^

ProtocolError: Page.printToPDF timed out. Increase the 'protocolTimeout' setting in launch/connect calls for a higher timeout if needed.
    at <instance_members_initializer> (C:\Users\docascode\AppData\Roaming\npm\node_modules\@marp-team\marp-cli\node_modules\puppeteer-core\lib\cjs\puppeteer\common\CallbackRegistry.js:96:14)
    at new Callback (C:\Users\docascode\AppData\Roaming\npm\node_modules\@marp-team\marp-cli\node_modules\puppeteer-core\lib\cjs\puppeteer\common\CallbackRegistry.js:100:16)
    at CallbackRegistry.create (C:\Users\docascode\AppData\Roaming\npm\node_modules\@marp-team\marp-cli\node_modules\puppeteer-core\lib\cjs\puppeteer\common\CallbackRegistry.js:32:26)
    at Connection._rawSend (C:\Users\docascode\AppData\Roaming\npm\node_modules\@marp-team\marp-cli\node_modules\puppeteer-core\lib\cjs\puppeteer\cdp\Connection.js:91:26)
    at CdpCDPSession.send (C:\Users\docascode\AppData\Roaming\npm\node_modules\@marp-team\marp-cli\node_modules\puppeteer-core\lib\cjs\puppeteer\cdp\CDPSession.js:78:33)
    at CdpPage.createPDFStream (C:\Users\docascode\AppData\Roaming\npm\node_modules\@marp-team\marp-cli\node_modules\puppeteer-core\lib\cjs\puppeteer\cdp\Page.js:823:63)
    at CdpPage.pdf (C:\Users\docascode\AppData\Roaming\npm\node_modules\@marp-team\marp-cli\node_modules\puppeteer-core\lib\cjs\puppeteer\cdp\Page.js:850:37)
    at C:\Users\docascode\AppData\Roaming\npm\node_modules\@marp-team\marp-cli\lib\marp-cli-MTD3MMmz.js:43:92026
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Yp.usePuppeteer (C:\Users\docascode\AppData\Roaming\npm\node_modules\@marp-team\marp-cli\lib\marp-cli-MTD3MMmz.js:43:97915)

Node.js v18.12.1
Vikramsingh-karnot commented 2 months ago

hey @yhatt any idea? or you want entire logs?

yhatt commented 2 months ago

I'm not familiar with Azure Pipelines and probably it's difficult to point out what happening accurately. So please don't rush me and don't emphasize frustrations just because you're in trouble. Maintainers and contributors are not support staff, and our open source projects are entirely voluntary.

Recommend to use GitHub Discussions instead of GitHub Issues for asking help to Marp community. See again our support guideline. https://github.com/orgs/marp-team/discussions https://github.com/marp-team/.github/blob/master/SUPPORT.md#how-about-github-issues

To debug your case, you should provide enough informations or minimal reproducible example that answerers can reproduce your environment. (e.g., Marp CLI version, Microsoft Edge version, and input Markdown files)

It is also worth trying to check:

Vikramsingh-karnot commented 2 months ago

Hey buddy, first of all, I'm not emphasizing frustrations on you so relax. I was just curious to know that's why I asked if you need any additional logs. 😊 I will try fix it!😊

yhatt commented 2 months ago

Uh ok, don't mind. Maybe I'm just tired. 🍵 I think that the context around CLI is important than extra logs.

Some environments are known as incompatible with Chromium sandbox. CLI will automatically disable sandbox if it is running on inside the container, but may be suitable to CI environment too.