mermaid-js / mermaid-cli

Command line tool for the Mermaid library
MIT License
2.43k stars 229 forks source link

Docker image failure #762

Open AlexisBRENON opened 1 week ago

AlexisBRENON commented 1 week ago

Describe the bug With the newest versions of the docker image, I'm not able to render my chart anymore. The process hangs for a while and finally crash with the following error:

ProtocolError: Network.enable timed out. Increase the 'protocolTimeout' setting in launch/connect calls for a higher timeout if needed.
    at <instance_members_initializer> (file:///home/mermaidcli/node_modules/puppeteer-core/lib/esm/puppeteer/common/CallbackRegistry.js:89:14)
    at new Callback (file:///home/mermaidcli/node_modules/puppeteer-core/lib/esm/puppeteer/common/CallbackRegistry.js:93:16)
    at CallbackRegistry.create (file:///home/mermaidcli/node_modules/puppeteer-core/lib/esm/puppeteer/common/CallbackRegistry.js:19:26)
    at Connection._rawSend (file:///home/mermaidcli/node_modules/puppeteer-core/lib/esm/puppeteer/cdp/Connection.js:86:26)
    at CdpCDPSession.send (file:///home/mermaidcli/node_modules/puppeteer-core/lib/esm/puppeteer/cdp/CDPSession.js:63:33)
    at NetworkManager.addClient (file:///home/mermaidcli/node_modules/puppeteer-core/lib/esm/puppeteer/cdp/NetworkManager.js:59:20)
    at FrameManager.initialize (file:///home/mermaidcli/node_modules/puppeteer-core/lib/esm/puppeteer/cdp/FrameManager.js:1[67](https://github.com/greenbids/greenbids-tailor-external/actions/runs/11270373229/job/31340948174#step:4:68):38)
    at #initialize (file:///home/mermaidcli/node_modules/puppeteer-core/lib/esm/puppeteer/cdp/Page.js:280:36)
    at CdpPage._create (file:///home/mermaidcli/node_modules/puppeteer-core/lib/esm/puppeteer/cdp/Page.js:93:31)
    at file:///home/mermaidcli/node_modules/puppeteer-core/lib/esm/puppeteer/cdp/Target.js:202:32

To Reproduce

  1. Create a file test.mmd:

    sequenceDiagram
      A ->>+ B: hello
      B -->>- A: ""
  2. Render the chart with old docker image:

    docker run --rm -u $(id -u) -v $PWD:/data ghcr.io/mermaid-js/mermaid-cli/mermaid-cli:11.2.1-beta.3 -i /data/test.mmd
  3. Render the chart with new docker image:

    docker run --rm -u $(id -u) -v $PWD:/data ghcr.io/mermaid-js/mermaid-cli/mermaid-cli:11.2.1 -i /data/test.mmd

Expected behavior I expected the rendering to succeed as previously.

Additional context You may see more examples in my repository which uses the image as part of the CI.

aloisklink commented 1 week ago

I can't replicate this issue on my local machine using:

cat test-positive/flowchart1.mmd | docker run --rm -i ghcr.io/mermaid-js/mermaid-cli/mermaid-cli:11.2.1 --input - --output - --outputFormat svg

However, I have replicated this using GitHub Codespaces (which I believe uses similar machines to the default GitHub Actions runners), and I'm having the same issue. ghcr.io/mermaid-js/mermaid-cli/mermaid-cli:11.2.1 doesn't work, but ghcr.io/mermaid-js/mermaid-cli/mermaid-cli:11.2.1-beta.5 works.

image

Edit: Ah, I think I might know the issue. The -beta.x Docker images are built using DockerfileBuild, which uses Apline Linux 3.19:

https://github.com/mermaid-js/mermaid-cli/blob/082fd7fbfcef41a8d968a895ea45b68dde75110a/DockerfileBuild#L15

However, the production Docker images are built using the Dockerfile, which uses the latest version of Alpine Linux (currently 3.20): https://github.com/mermaid-js/mermaid-cli/blob/082fd7fbfcef41a8d968a895ea45b68dde75110a/Dockerfile#L1

However, it looks like version of Chromium in Apline Linux 3.20 doesn't play nicely with Puppeteer: https://github.com/puppeteer/puppeteer/issues/12637

I'm not 100% sure why we have both a Dockerfile and a DockerfileBuild, but I suspect just using the same one for everything should fix this issue.