Mermaid.js default character limit is too low #13474

Closed
opened 2025-11-02 10:43:28 -06:00 by GiteaMirror · 6 comments
Owner

Originally created by @neon-dev on GitHub (Sep 9, 2024).

Description

Mermaid.js has a default maxTextSize of 50000:
dd0304387e/packages/mermaid/src/schemas/config.schema.yaml (L95-L98)

Can we increase
a323a82ec4/modules/setting/markup.go (L64)
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

Originally created by @neon-dev on GitHub (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 https://github.com/go-gitea/gitea/blob/a323a82ec4bde6ae39b97200439829bf67c0d31e/modules/setting/markup.go#L64 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
GiteaMirror added the type/proposal label 2025-11-02 10:43:28 -06:00
Author
Owner

@yp05327 commented on GitHub (Sep 10, 2024):

But this is configurable.

@yp05327 commented on GitHub (Sep 10, 2024): But this is configurable.
Author
Owner

@neon-dev commented on GitHub (Sep 10, 2024):

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

@neon-dev commented on GitHub (Sep 10, 2024): Is there a reason to keep the default value different from what the creators of mermaid.js intended?
Author
Owner

@yp05327 commented on GitHub (Sep 10, 2024):

I don't know why, but I found this: https://github.com/go-gitea/gitea/issues/16513#issuecomment-885006410
Maybe 5000 is older than this default value.

@yp05327 commented on GitHub (Sep 10, 2024): I don't know why, but I found this: https://github.com/go-gitea/gitea/issues/16513#issuecomment-885006410 Maybe 5000 is older than this default value.
Author
Owner

@neon-dev commented on GitHub (Sep 10, 2024):

Looks like there was no limit a few years ago: 4ad354a561
Maybe the config value in Gitea should become optional then?

@neon-dev commented on GitHub (Sep 10, 2024): Looks like there was no limit a few years ago: https://github.com/mermaid-js/mermaid/commit/4ad354a561a941d968ebf8b91edf0309c0fe0d03 Maybe the config value in Gitea should become optional then?
Author
Owner

@neon-dev commented on GitHub (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.

@neon-dev commented on GitHub (Sep 13, 2024): I also checked out [GitLab's original implementation](https://gitlab.com/gitlab-org/gitlab/-/commit/fec31b7165aec888e3306c3ad8717eab05346b7b) 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](https://gitlab.com/gitlab-org/gitlab/-/blob/da863bc6/app/assets/javascripts/behaviors/markdown/render_sandboxed_mermaid.js#L149-150) on a page.
Author
Owner

@wxiaoguang commented on GitHub (Apr 8, 2025):

Can we increase ... to the same value?

Sure: Set MERMAID_MAX_SOURCE_CHARACTERS to 50000 #34152

@wxiaoguang commented on GitHub (Apr 8, 2025): > Can we increase ... to the same value? Sure: Set MERMAID_MAX_SOURCE_CHARACTERS to 50000 #34152
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#13474