Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Too many edges error #5042

Closed
jvieille opened this issue Nov 18, 2023 · 9 comments · Fixed by #5086
Closed

Too many edges error #5042

jvieille opened this issue Nov 18, 2023 · 9 comments · Fixed by #5086
Labels
Status: Triage Needs to be verified, categorized, etc Type: Bug / Error Something isn't working or is incorrect

Comments

@jvieille
Copy link

jvieille commented Nov 18, 2023

mermaid.txt

Description

When a flowchart becomes large, Mermaid dismisses the graphing and fails with a "Syntax error" splash. The JS console tells "Too many edges" from mermaid.min.js related to the MPt function, which occurs if something (number of edges ?) to be higher than 280.
MPt = function(i, a, f) { const m = { start: i, end: a, type: void 0, text: "", labelType: "text" }; Ut.info("abc78 Got edge...", m); const b = f.text; if (b !== void 0 && (m.text = cY(b.text.trim()), m.text[0] === '"' && m.text[m.text.length - 1] === '"' && (m.text = m.text.substring(1, m.text.length - 1)), m.labelType = b.type), f !== void 0 && (m.type = f.type, m.stroke = f.stroke, m.length = f.length), (m == null ? void 0 : m.length) > 10 && (m.length = 10), gk.length < 280) Ut.info("abc78 pushing edge..."), gk.push(m); else throw new Error("Too many edges")

Attached the Chrome consol log
sbm-v1.agharen.fr-1700294922137.log

Steps to reproduce

Create a large flow chart, if big enough, the issue will occur.
The problem seems to occur above a 50 Kb script, the attached file is 84 Kb, 1200 lines, 300-400 edges.

Current initialization:
mermaid.initialize({startOnLoad:true, logLevel: 1, theme: 'neutral', maxTextSize: 5000000, MAX_CHAR_LIMIT: 5000000 });

Screenshots

No response

Code Sample

No response

Setup

  • Mermaid version: 10.6.1
  • Browser and Version: Chrome

Suggested Solutions

Increase significantly this limitation or make it adjustable.
I am now using successfully a local copy of mermaid.min.js with that number increased from 280 to 2000

Additional Context

No response

@jvieille jvieille added Status: Triage Needs to be verified, categorized, etc Type: Bug / Error Something isn't working or is incorrect labels Nov 18, 2023
@mken418
Copy link

mken418 commented Nov 21, 2023

I also got this error in the online editor and CLI on mac. After using a similar hack mmdc generates an image just fine. This would be better if if was a config parameter. My mmd graph file was 11kb, 531 lines

sudo vi /usr/local/lib/node_modules/@mermaid-js/mermaid-cli/dist/index.html
Line 103 change gb.length<280 to gb.length<2000

@mozziemozz
Copy link

mozziemozz commented Nov 22, 2023

@mken418 how did you generate the image using mmdc? I tried to change that value from 280 to 2000 as well but it doesn't work for me. I'm on Windows 11 though. I tried both, converting a markdown file which contains a diagram and a *.mmd file as well.

I tried using this: mmdc -i "test.md" -o "test.png" -s 10

Chaning the value to <2000 and adding a config file as described here, worked for me.

Thanks

@lix0x7
Copy link

lix0x7 commented Nov 24, 2023

I just downgrade to 10.5.0 and it helps. The limit 280 is hardcoded. There is no way to change it.

@mhosman
Copy link

mhosman commented Nov 24, 2023

Same issue here, even mermaid.initialize with setting maxTextSize ignores the value.

@sidharthv96
Copy link
Member

fc28c1d was where the check was added. This limit should be increased, and be made configurable.

@pbrolin47 you were facing the same issue from another user report right?

@DefamationStation
Copy link

Hello, I tried to create a diagram with 750 points and I have the same message.

@sidharthv96
Copy link
Member

@DefamationStation are diagrams with that many edges a common scenario? Also, are you using mermaid.live for this?
In #5086, we've set the limit to 500, with an option to configure it when initializing mermaid.
We are planning to keep a higher limit, maybe 1000-2000 in mermaid.live.

@DefamationStation
Copy link

@DefamationStation are diagrams with that many edges a common scenario? Also, are you using mermaid.live for this?
In #5086, we've set the limit to 500, with an option to configure it when initializing mermaid.
We are planning to keep a higher limit, maybe 1000-2000 in mermaid.live.

Hello

It's not the standard but I've got some scenarios where I am using a lot of nodes to plot routes throughout cities!

Yes mermaid.live

Thats very good to hear thank you!

github-merge-queue bot pushed a commit that referenced this issue Dec 10, 2023
feat #5042: Add `flowchart.maxEdges` config.
b7woreo added a commit to b7woreo/GradleAssistant that referenced this issue Dec 16, 2023
@mlandisbqs
Copy link

Hi - is there anyway to configure this with the mermaid CLI, or the jetbrains plugin? I tried using -c [configfile] but still get the error (with version 10.6.1). frontmatter config doesn't seem to work either. I have ~750 lines of graph LR in the markdown file...

cat .stats.mermaid.json

{
  "maxEdges": 1000
}
npx @mermaid-js/mermaid-cli -c .stats.mermaid.json -i .stats.mermaid.md -o .stats.diagram.svg
Found 1 mermaid charts in Markdown input

Error: Evaluation failed: Error: Too many edges
    at dbt (file:///Users/mlandis/.npm/_npx/668c188756b835f3/node_modules/@mermaid-js/mermaid-cli/dist/index.html:103:13448)
    at Object.Fbt [as addLink] (file:///Users/mlandis/.npm/_npx/668c188756b835f3/node_modules/@mermaid-js/mermaid-cli/dist/index.html:103:13584)
    at Object.performAction (file:///Users/mlandis/.npm/_npx/668c188756b835f3/node_modules/@mermaid-js/mermaid-cli/dist/index.html:98:6972)
    at Lh.parse (file:///Users/mlandis/.npm/_npx/668c188756b835f3/node_modules/@mermaid-js/mermaid-cli/dist/index.html:100:892)
    at PUt.parse (file:///Users/mlandis/.npm/_npx/668c188756b835f3/node_modules/@mermaid-js/mermaid-cli/dist/index.html:64:512)
    at new PUt (file:///Users/mlandis/.npm/_npx/668c188756b835f3/node_modules/@mermaid-js/mermaid-cli/dist/index.html:64:247)
    at GjA (file:///Users/mlandis/.npm/_npx/668c188756b835f3/node_modules/@mermaid-js/mermaid-cli/dist/index.html:64:824)
    at async Object.N2e [as render] (file:///Users/mlandis/.npm/_npx/668c188756b835f3/node_modules/@mermaid-js/mermaid-cli/dist/index.html:87:1146)
    at ExecutionContext._ExecutionContext_evaluate (file:///Users/mlandis/.npm/_npx/668c188756b835f3/node_modules/puppeteer-core/lib/esm/puppeteer/common/ExecutionContext.js:254:15)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async ExecutionContext.evaluate (file:///Users/mlandis/.npm/_npx/668c188756b835f3/node_modules/puppeteer-core/lib/esm/puppeteer/common/ExecutionContext.js:143:16)
    at async CDPJSHandle.evaluate (file:///Users/mlandis/.npm/_npx/668c188756b835f3/node_modules/puppeteer-core/lib/esm/puppeteer/common/JSHandle.js:56:16)
    at async CDPElementHandle.$eval (file:///Users/mlandis/.npm/_npx/668c188756b835f3/node_modules/puppeteer-core/lib/esm/puppeteer/common/ElementHandle.js:86:24)
    at async renderMermaid (file:///Users/mlandis/.npm/_npx/668c188756b835f3/node_modules/@mermaid-js/mermaid-cli/src/index.js:246:22)
    at async file:///Users/mlandis/.npm/_npx/668c188756b835f3/node_modules/@mermaid-js/mermaid-cli/src/index.js:442:41
    at async Promise.all (index 0)
    at async run (file:///Users/mlandis/.npm/_npx/668c188756b835f3/node_modules/@mermaid-js/mermaid-cli/src/index.js:461:22)
    at async cli (file:///Users/mlandis/.npm/_npx/668c188756b835f3/node_modules/@mermaid-js/mermaid-cli/src/index.js:184:3)=

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Triage Needs to be verified, categorized, etc Type: Bug / Error Something isn't working or is incorrect
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants