mermaid-js / mermaid-cli

Command line tool for the Mermaid library
MIT License
2.35k stars 227 forks source link

Version 10.2.2 of mermaid-cli fails to generate a mindmap (puppeteer timeout or crashes) #556

Closed kenseii closed 1 year ago

kenseii commented 1 year ago

Describe the bug

After installing the latest version of mermaid-cli (10.2.2) and attempting to generate a mindmap svg using it, it always failed with a timeout error or sometimes a target crashed error. Puppeteer recently released 1.4.2 https://github.com/puppeteer/puppeteer/releases/tag/browsers-v1.4.2 and my guess is that this new update has some breaking changes

To Reproduce Steps to reproduce the behavior:

  1. Install mermaid with npm npm install -g @mermaid-js/mermaid-cli
  2. Set your puppeteer config to look like this
    {
    "headless": "new",
    "args": ["--disable-dev-shm-usage","--no-first-run","--disable-setuid-sandbox", "--no-zygote", "--disable-dev-shm-usage", "--disable-gpu"]
    }
  3. run
    cat << EOF  | mmdc -p puppeteer-config.json --input -
    mindmap
    root(("午後4時9分"))
    "全体の概要"
        "エブリータイム4のニュースとスポーツ"
        "強盗事件の機金属店の東京上野での逮捕"
        "メイク持続シートによるメイクの密着ロック"
        "インディードで見つけた希望の仕事"
        "旅行のジャランスペシャルウィークプラン"
    "興味深い広告"
        "ハーゲンダッツのハロー幸せ"
        "密着ロックのメイク持続シート"
        "エムリーの綺麗なつづき"
    "逮捕の詳細"
        "実行役の2人が逮捕された強盗事件"
        "5月に発生した上野の機金属店"
        "ネックレスなどを強奪した後、男が逃走"
    "新製品とサービス"
        "アクエリアスの新しいウォーター"
        "カラッチョで糖や脂肪の吸収を抑える"
        "キリンの免疫ケアで内側から守る"
    "気象予報"
        "東京上野の非禁毒店で発生した冒頭事件"
        "2人の逮捕された男らの実行役"
        "61歳の男が韓国への究極の化粧品を作成"
        "岡場厳重警戒中"
    EOF
  4. This command should take some time and finally return this error
  5. See the error
    ProtocolError: Runtime.callFunctionOn timed out. Increase the 'protocolTimeout' setting in launch/connect calls for a higher timeout if needed.
    at new Callback (file:///opt/homebrew/lib/node_modules/@mermaid-js/mermaid-cli/node_modules/puppeteer-core/lib/esm/puppeteer/common/Connection.js:58:35)
    at CallbackRegistry.create (file:///opt/homebrew/lib/node_modules/@mermaid-js/mermaid-cli/node_modules/puppeteer-core/lib/esm/puppeteer/common/Connection.js:103:26)
    at Connection._rawSend (file:///opt/homebrew/lib/node_modules/@mermaid-js/mermaid-cli/node_modules/puppeteer-core/lib/esm/puppeteer/common/Connection.js:212:26)
    at CDPSessionImpl.send (file:///opt/homebrew/lib/node_modules/@mermaid-js/mermaid-cli/node_modules/puppeteer-core/lib/esm/puppeteer/common/Connection.js:419:78)
    at ExecutionContext._ExecutionContext_evaluate (file:///opt/homebrew/lib/node_modules/@mermaid-js/mermaid-cli/node_modules/puppeteer-core/lib/esm/puppeteer/common/ExecutionContext.js:236:46)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async ExecutionContext.evaluate (file:///opt/homebrew/lib/node_modules/@mermaid-js/mermaid-cli/node_modules/puppeteer-core/lib/esm/puppeteer/common/ExecutionContext.js:143:16)
    at async CDPJSHandle.evaluate (file:///opt/homebrew/lib/node_modules/@mermaid-js/mermaid-cli/node_modules/puppeteer-core/lib/esm/puppeteer/common/JSHandle.js:56:16)
    at async CDPElementHandle.$eval (file:///opt/homebrew/lib/node_modules/@mermaid-js/mermaid-cli/node_modules/puppeteer-core/lib/esm/puppeteer/common/ElementHandle.js:86:24)
    at async renderMermaid (file:///opt/homebrew/lib/node_modules/@mermaid-js/mermaid-cli/src/index.js:237:22)

Expected behavior The same command and config should fail on 10.2.2 but work if you run it using 10.1.0

Desktop (please complete the following information):

aloisklink commented 1 year ago

Thank you for the great and detailed bug report! I've tested and this actually seems to be a bug in Mermaid v10.2.2, see https://github.com/mermaid-js/mermaid/issues/4408.

It's been fixed by Mermaid v10.2.3.

Unfortunately, we haven't yet made a new release of mermaid-cli yet. As a temporary measure, you can run npm install github:mermaid-js/mermaid-cli to install the latest in-development version on GitHub.

@MindaugasLaganeckas, can you make a v10.2.4 release to NPM, since Mermaid v10.2.4 has come out recently, see


By the way, "headless": "new" in my puppeteer config seems to be a bit buggy. It might be worth keeping the old "headless": true setting if you want a more stable experience, at least until the Puppeteer team improves the new headless mode.

aloisklink commented 1 year ago

This has been fixed with @mermaid-js/mermaid-cli v10.2.4 (the puppeteer config file you gave doesn't seem to work, but using no puppeteer config file seems to be fine)!

Thanks again for raising this issue!

BenGlasser commented 1 month ago

I'm having this issue on 10.9.1 with no puppeteer config