Skip to content

Mermaid.js default character limit is too low #32015

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

Closed
neon-dev opened this issue Sep 9, 2024 · 6 comments · Fixed by #34152
Closed

Mermaid.js default character limit is too low #32015

neon-dev opened this issue Sep 9, 2024 · 6 comments · Fixed by #34152
Labels
type/proposal The new feature has not been accepted yet but needs to be discussed first.
Milestone

Comments

@neon-dev
Copy link

neon-dev commented Sep 9, 2024

Description

Mermaid.js has a default maxTextSize of 50000:
https://github.com/mermaid-js/mermaid/blob/dd0304387e85fc57a9ebb666f89ef788c012c2c5/packages/mermaid/src/schemas/config.schema.yaml#L95-L98

Can we increase

MermaidMaxSourceCharacters = rootCfg.Section("markup").Key("MERMAID_MAX_SOURCE_CHARACTERS").MustInt(5000)

to the same value?

Gitea Version

1.22.2

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

No response

Screenshots

No response

Git Version

No response

Operating System

No response

How are you running Gitea?

Database

None

@neon-dev neon-dev changed the title Mermaid.js character limit is too low Mermaid.js default character limit is too low Sep 9, 2024
@yp05327
Copy link
Contributor

yp05327 commented Sep 10, 2024

But this is configurable.

@neon-dev
Copy link
Author

Is there a reason to keep the default value different from what the creators of mermaid.js intended?

@yp05327
Copy link
Contributor

yp05327 commented Sep 10, 2024

I don't know why, but I found this: #16513 (comment)
Maybe 5000 is older than this default value.

@neon-dev
Copy link
Author

Looks like there was no limit a few years ago: mermaid-js/mermaid@4ad354a
Maybe the config value in Gitea should become optional then?

@neon-dev
Copy link
Author

neon-dev commented Sep 13, 2024

I also checked out GitLab's original implementation of the character limit that was mentioned in your linked comment. It is just supposed to defer rendering of larger graphs so it doesn't slow down the initial page load. There is no hard limit that denies rendering them altogether like Gitea currently handles this. And from my limited testing on GitHub, they don't even seem to have any limit or it is not triggered easily.

In summary, Gitea's current implementation and default value try to solve one issue by creating an entirely new one: Not being able to render a graph.
I suggest evaluating at what threshold performance issues start to ocurr (should only happen with multiple graphs on a page) and deciding a new strategy to handle such cases. GitLab also revised their strategy with a later commit by tracking how many elements have been rendered in total on a page.

@wxiaoguang
Copy link
Contributor

Can we increase ... to the same value?

Sure: Set MERMAID_MAX_SOURCE_CHARACTERS to 50000 #34152

@lunny lunny added type/proposal The new feature has not been accepted yet but needs to be discussed first. and removed type/bug labels Apr 8, 2025
@lunny lunny added this to the 1.24.0 milestone Apr 8, 2025
project-mirrors-bot-tu bot pushed a commit to project-mirrors/forgejo-as-gitea-fork that referenced this issue Apr 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/proposal The new feature has not been accepted yet but needs to be discussed first.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants