mermaid-js / mermaid

Generation of diagrams like flowcharts or sequence diagrams from text in a similar manner as markdown
https://mermaid.js.org
MIT License
72.33k stars 6.59k forks source link

Cannot read property 'initialize' of undefined #1761

Closed RobertHue closed 1 year ago

RobertHue commented 4 years ago

Hello! I'm experiencing the following issue:

(etf) rhuemmer@PCAED685:~/etf$ ./node_modules/.bin/mmdc -i ./doc/sphinx/source/hardware/linux/tcp_client.mmd -o test.png -p ./doc/sphinx/source/puppeteer-config.json 
/home/rhuemmer/etf/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:217
            throw new Error('Evaluation failed: ' + helper_js_1.helper.getExceptionMessage(exceptionDetails));
                  ^

Error: Evaluation failed: TypeError: Cannot read property 'initialize' of undefined
    at __puppeteer_evaluation_script__:3:20
    at ExecutionContext._evaluateInternal (/home/rhuemmer/etf/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:217:19)
    at processTicksAndRejections (node:internal/process/task_queues:93:5)
    at async ExecutionContext.evaluate (/home/rhuemmer/etf/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:106:16)
    at async ElementHandle.evaluate (/home/rhuemmer/etf/node_modules/puppeteer/lib/cjs/puppeteer/common/JSHandle.js:102:16)
    at async ElementHandle.$eval (/home/rhuemmer/etf/node_modules/puppeteer/lib/cjs/puppeteer/common/JSHandle.js:650:24)
(etf) rhuemmer@PCAED685:~/etf$

Puppeteer und mermaid.cli are the latest version:

(etf) rhuemmer@PCAED685:~/etf$ npm list --depth=1
etf@ /home/rhuemmer/etf
├─┬ @mermaid-js/mermaid-cli@8.8.2-beta.8
│ ├── chalk@4.1.0
│ ├── commander@6.2.0
│ └── puppeteer@5.4.1
├─┬ bufferutil@4.0.2
│ └── node-gyp-build@4.2.3
├─┬ chromium@3.0.2
│ ├── cachedir@2.3.0
│ ├── debug@4.2.0
│ ├── extract-zip@1.7.0
│ ├── got@11.8.0
│ ├── progress@2.0.3
│ ├── rimraf@2.7.1
│ ├── tmp@0.0.33
│ └── tunnel@0.0.6
└─┬ utf-8-validate@5.0.3
  └── node-gyp-build@4.2.3 deduped

Version of node and nodejs:

(etf) rhuemmer@PCAED685:~/etf$ nodejs -v
v8.10.0
(etf) rhuemmer@PCAED685:~/etf$ node -v
v15.0.1

This issue is related to: https://github.com/mermaid-js/mermaid/issues/662 I also already asked at https://github.com/mermaid-js/mermaid-cli/issues/70, but it turned out that mermaid-cli is just a thin-layer and I should address my question to the mermaid library. What could be the problem? Is this a bug or some configuration problem on my side?

SCOTT-HAMILTON commented 3 years ago

I can reproduce with a nix shell :

  1. Install nix https://nixos.org/guides/install-nix.html
  2. write this to shell.nix :
    { pkgs ? import (builtins.fetchTarball {
    url = "http://github.com/NixOS/nixpkgs/archive/91b77fe6942fe999b1efbe906dc98024d1917c0d.tar.gz";
    sha256 = "041l46ccllbf9b94jxahw64zsjxs1368y4m5a5q2h41w82jjmdk1";
    }) {},
    shamilton ?
    import (builtins.fetchTarball {
    url = "http://github.com/SCOTT-HAMILTON/nur-packages-template/archive/1ed406b2ef43ffb71703e4ec4388692bbda40476.tar.gz";
    sha256 = "1v8d6vg3d61jp7sh7va3s6v34lrxpczkdvad1hqadlwc05fw2cb8";
    }) {}
    }:
    pkgs.mkShell {
    buildInputs = with shamilton; [ mermaid-cli ];
    shellHook = ''
    cat << EOF | mmdc
      sequenceDiagram
        Tabbed Client 1->>+Alacritty Tab 1: Hello Alacritty, what's your X11 Window Identifier ?
        Alacritty Tab 1-->>-Tabbed Client 1: Hi, my XID is 138412034.
    EOF
    '';
    }
  3. run the shell :
    $ nix-shell

    Output :

    (node:19275) UnhandledPromiseRejectionWarning: Error: Evaluation failed: TypeError: Cannot read property 'initialize' of undefined
    at __puppeteer_evaluation_script__:3:20
    at ExecutionContext._evaluateInternal (/nix/store/c15qvj0ykw72vamn5lk9n4xhzai9568h-node_mermaid-cli-8.9.2/lib/node_modules/@mermaid-js/mermaid-cli/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:218:19)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async ExecutionContext.evaluate (/nix/store/c15qvj0ykw72vamn5lk9n4xhzai9568h-node_mermaid-cli-8.9.2/lib/node_modules/@mermaid-js/mermaid-cli/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:107:16)
    at async ElementHandle.evaluate (/nix/store/c15qvj0ykw72vamn5lk9n4xhzai9568h-node_mermaid-cli-8.9.2/lib/node_modules/@mermaid-js/mermaid-cli/node_modules/puppeteer/lib/cjs/puppeteer/common/JSHandle.js:102:16)
    at async ElementHandle.$eval (/nix/store/c15qvj0ykw72vamn5lk9n4xhzai9568h-node_mermaid-cli-8.9.2/lib/node_modules/@mermaid-js/mermaid-cli/node_modules/puppeteer/lib/cjs/puppeteer/common/JSHandle.js:650:24)
    at async /nix/store/c15qvj0ykw72vamn5lk9n4xhzai9568h-node_mermaid-cli-8.9.2/lib/node_modules/@mermaid-js/mermaid-cli/index.js:130:18
    (node:19275) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
    (node:19275) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Expected output :

knsv commented 3 years ago

Hi! I think this is posted in the wrong repo. The mermaid-cli project is here: https://github.com/mermaid-js/mermaid-cli Perhaps you can add an issue there refering to this one?

SCOTT-HAMILTON commented 3 years ago

Hi! I think this is posted in the wrong repo. The mermaid-cli project is here: https://github.com/mermaid-js/mermaid-cli Perhaps you can add an issue there refering to this one?

An attempt has already been done here and the mermaid-cli guys said that they couldn't do much, it had to be something with mermaid itself.

knsv commented 3 years ago

OK, we will work together on it then.

korompaiistvan commented 3 years ago

just ran into this myself. my diagram is fairly long. should I post it here nonetheless?

kolodach commented 2 years ago

Run into the same issue recently. As a temporary solution, you can adjust your puppeteer json file with these arguments:

{
  "args": [
            "--disable-gpu",
            "--disable-dev-shm-usage",
            "--disable-setuid-sandbox",
            "--no-first-run",
            "--no-sandbox",
            "--no-zygote",
            "--single-process"]
}

Tested on WSL2 Ubuntu 20.04 - fixed issue for me. Original solution: https://github.com/puppeteer/puppeteer/issues/1837#issuecomment-534075536