Skip to content
This repository has been archived by the owner on Jul 22, 2023. It is now read-only.

Unhandled exception when trying to convert mmd file #16

Closed
angrykoala opened this issue Nov 6, 2017 · 16 comments
Closed

Unhandled exception when trying to convert mmd file #16

angrykoala opened this issue Nov 6, 2017 · 16 comments

Comments

@angrykoala
Copy link

angrykoala commented Nov 6, 2017

When executing mmdc -i my_file.mmd with node 6.11.5 in mermaidCLI 0.3.1, the following exception happens:

(node:29742) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: spawn EACCES

Same issue when using node 8 and 9

The minimal file I tried:

graph LR
A-->B;
@agusmba
Copy link
Contributor

agusmba commented Nov 6, 2017

It seems one of the changes in the last commit 1f9a6bc is breaking also the dev version.

I'll try to narrow it down

@agusmba
Copy link
Contributor

agusmba commented Nov 6, 2017

In my case it's puppetteer's new version (with new chrome) giving me grief.

@agusmba
Copy link
Contributor

agusmba commented Nov 6, 2017

In windows, the problem seems to be with my antivirus, for some reason it won't let me execute chrome when I use puppeteer 0.12.0 instead of 0.11.0.

I tried with a dockerized node 8.9 and again run into problems, with both mermaid.cli 0.2.1 and 0.3.1

It could be tracked down to puppeteer/puppeteer#290 (comment)
I tried the workaround there of using {args: ['--no-sandbox', '--disable-setuid-sandbox']} and it worked, but this is not an acceptable solution security-wise.

@agusmba
Copy link
Contributor

agusmba commented Nov 6, 2017

Maybe @tylerlong can take a look...
@angrykoala could you also check https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md

just in case there are some dependencies missing at the OS level?

@angrykoala
Copy link
Author

@agusmba All dependencies are installed in my system, and it is werid that it is a dependency when the problem is explicitly about an unhandled promise

@agusmba
Copy link
Contributor

agusmba commented Nov 6, 2017

The problem appears to be puppeteer failing to properly launch chrome. There seem to be many different reasons for failing to launch chrome, like an antivirus (my case), missing deps, or lack of kernel support.

Does mermaid.cli version 0.2.1 work for you?

@angrykoala
Copy link
Author

Trying to install/uninstall (as sudo) mermaid.cli globally fails with the following error:

fs.js:885                                                                                                                                                      
  return binding.mkdir(pathModule._makeLong(path),                                                                                                             
                 ^                                                                                                                                             
                                                                                                                                                               
Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/mermaid.cli/node_modules/puppeteer/.local-chromium'                                       

I'm not sure if this error is related or may help to this issue

@agusmba
Copy link
Contributor

agusmba commented Nov 6, 2017

For what it's worth, version 0.3.1 is working fine on my windows 7 box (no antivirus issues either), node v6.11.0

@angrykoala it sure looks like there's a problem with your puppeteer / chromium

@agusmba
Copy link
Contributor

agusmba commented Nov 7, 2017

0.3.1 also working on my windows 10 (convinced the antivirus that chrome.exe is safe).

@lf-araujo
Copy link

Can confirm this happens in Ubuntu 17.10.

@diversemix
Copy link

Manually fettling package.json to include v0.13.0 of puppeteer within the mermaid.cli package seems to have got the mmdc working for me.

diversemix pushed a commit to diversemix/mermaid.cli that referenced this issue Jan 1, 2018
This solves the issue with an UnhandledPromiseRejectionWarning issue mermaidjs#16
@diversemix
Copy link

Ok ... As part of my testing I reverted the version of puppeteer back to 0.12 to make sure it still did not work ... but it did work. This is confusing as now everything is working fine and I cannot get things to break again. Leaving this here in case it helps!

@tylerlong
Copy link
Contributor

I cannot reproduce the issue you reported.

If you are having issues, please try the following:

  1. Install mermaid.cli locally instead of globally. And invoke the binary by ./node_modules/.bin/mmdc. Sometime YARN or NPM just failed to install this library globally properly due to some weird permission issues. Installing it locally will fix the issue.
  2. Upgrade your Node.js. Node 6.x is pretty old in my opinion. If there is nothing preventing your from upgrading why not just upgrade?
  3. If you are still experience this issue. Please reopen this issue or create a new issue and list the detailed steps to reproduce the issue(including your OS version, node version and the commands you issued.)

@Salzi
Copy link

Salzi commented Apr 12, 2018

@tylerlong
I have the same issue (can't reopen the issue). Here is what I did:

  • Install mermaid.cli locally sudo npm install mermaid.cli
  • locate shows now the global and the local executable:
locate mmdc
/home/jonas/Documents/node_modules/.bin/mmdc
/usr/lib/node_modules/mermaid-filter/node_modules/.bin/mmdc
  • Created a new file: my_file.mmd with the content
graph LR
A-->B;
  • Execute: /home/jonas/Documents/node_modules/.bin/mmdc -i my_file.mmd gives me the error:

(node:11047) UnhandledPromiseRejectionWarning: Error: spawn EACCES
at ChildProcess.spawn (internal/child_process.js:330:11)
at Object.exports.spawn (child_process.js:500:9)
at Function.launch (/home/jonas/Documents/node_modules/puppeteer/lib/Launcher.js:106:40)
at
(node:11047) 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(). (rejection id: 1)
(node:11047) [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.

My setup:
OS: Manjaro (Linux): Linux 4.4.126-1-MANJARO #1 SMP PREEMPT Sat Mar 31 17:16:02 UTC 2018
nodeJS: 9.9.0-2
mmdc: 0.4.5

Let me know if you need more information.

@tylerlong
Copy link
Contributor

tylerlong commented Apr 13, 2018

@Salzi

If you install it locally (in your current folder), you don't need to locate it at all.

Just ./node_modules/.bin/mmdc -i ...

The binary you located might not be the one you just installed.

And from the error message, it is a permission issue. You can try sudo.

@tylerlong
Copy link
Contributor

Tested on ubuntu Linux:

tyler@tyler-VirtualBox:~/src$ cd temp
tyler@tyler-VirtualBox:~/src/temp$ ls
flowchart.mmd
tyler@tyler-VirtualBox:~/src/temp$ yarn add mermaid.cli
yarn add v1.3.2
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
warning Your current version of Yarn is out of date. The latest version is "1.5.1" while you're on "1.3.2".
info To upgrade, run the following command:
$ sudo apt-get update && sudo apt-get install yarn
success Saved 49 new dependencies.
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
└─ [email protected]
Done in 43.44s.
tyler@tyler-VirtualBox:~/src/temp$ ./node_modules/.bin/mmdc -i flowchart.mmd 
tyler@tyler-VirtualBox:~/src/temp$ ls
flowchart.mmd  flowchart.mmd.svg  node_modules  package.json  yarn.lock
tyler@tyler-VirtualBox:~/src/temp$ ./node_modules/.bin/mmdc -i flowchart.mmd -o flowchart.png
tyler@tyler-VirtualBox:~/src/temp$ ./node_modules/.bin/mmdc -v

  error: unknown option `-v'

tyler@tyler-VirtualBox:~/src/temp$ ./node_modules/.bin/mmdc -V
0.4.6
tyler@tyler-VirtualBox:~/src/temp$ 

I am not going to test other Linux distributions because there are so many of them.
If it doesn't work for your distribution, it's probably not mermaid.cli's issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants