Skip to content

Conversation

@abroa01
Copy link

@abroa01 abroa01 commented Oct 24, 2025

Resolves #7006

render() immediately fails with TypeError: id of clusterDb.keys is not a function
Root Cause: Major regression introduced in Mermaid v11.0.0 where clusterDb objects are created as plain objects instead of Map instances, causing .keys() method to be undefined

Change :
Change the clusterDb assignment from plain objects to Map in a for loop

@changeset-bot
Copy link

changeset-bot bot commented Oct 24, 2025

⚠️ No Changeset found

Latest commit: 0d42b6b

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@netlify
Copy link

netlify bot commented Oct 24, 2025

Deploy Preview for mermaid-js ready!

Name Link
🔨 Latest commit 0d42b6b
🔍 Latest deploy log https://app.netlify.com/projects/mermaid-js/deploys/68fbb0dfa0d0a40008a32c3e
😎 Deploy Preview https://deploy-preview-7104--mermaid-js.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions github-actions bot added the Type: Bug / Error Something isn't working or is incorrect label Oct 24, 2025
@pkg-pr-new
Copy link

pkg-pr-new bot commented Oct 24, 2025

Open in StackBlitz

@mermaid-js/examples

npm i https://pkg.pr.new/mermaid-js/mermaid/@mermaid-js/examples@7104

mermaid

npm i https://pkg.pr.new/mermaid-js/mermaid@7104

@mermaid-js/layout-elk

npm i https://pkg.pr.new/mermaid-js/mermaid/@mermaid-js/layout-elk@7104

@mermaid-js/layout-tidy-tree

npm i https://pkg.pr.new/mermaid-js/mermaid/@mermaid-js/layout-tidy-tree@7104

@mermaid-js/mermaid-zenuml

npm i https://pkg.pr.new/mermaid-js/mermaid/@mermaid-js/mermaid-zenuml@7104

@mermaid-js/parser

npm i https://pkg.pr.new/mermaid-js/mermaid/@mermaid-js/parser@7104

@mermaid-js/tiny

npm i https://pkg.pr.new/mermaid-js/mermaid/@mermaid-js/tiny@7104

commit: 0d42b6b

@codecov
Copy link

codecov bot commented Oct 24, 2025

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 3.55%. Comparing base (fed8a52) to head (0d42b6b).
⚠️ Report is 39 commits behind head on develop.

Files with missing lines Patch % Lines
...g-util/layout-algorithms/dagre/mermaid-graphlib.js 0.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           develop   #7104      +/-   ##
==========================================
- Coverage     3.55%   3.55%   -0.01%     
==========================================
  Files          473     474       +1     
  Lines        47480   47491      +11     
  Branches       730     730              
==========================================
  Hits          1687    1687              
- Misses       45793   45804      +11     
Flag Coverage Δ
unit 3.55% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...g-util/layout-algorithms/dagre/mermaid-graphlib.js 0.00% <0.00%> (ø)

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@argos-ci
Copy link

argos-ci bot commented Oct 24, 2025

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
default (Inspect) ⚠️ Changes detected (Review) 1 changed Oct 24, 2025, 5:12 PM

@abroa01 abroa01 changed the title fix: Update mermaid-graphlib.js with latest changes fix: Update the clusterDb assignment from plain objects to Map in v11.12.0 Oct 27, 2025
Copy link
Member

@sidharthv96 sidharthv96 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@abroa01 can you add a unit test for this scenario as well?

Comment on lines +243 to 244
for (let id of Object.keys(clusterDb)) {
const nonClusterChild = clusterDb.get(id).id;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fix does not solve the root cause. Inside the for loop, clusterDb.get is called, which will fail.

This particular instance of clusterDb is created as a Map, so I don't understand why it's failing in Cordova.

https://github.com/abroa01/mermaid/blob/0d42b6b34bcd6f91f5d7f993adec3848ce84a600/packages/mermaid/src/rendering-util/layout-algorithms/dagre/mermaid-graphlib.js#L6-L7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Type: Bug / Error Something isn't working or is incorrect

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TypeError: id of clusterDb.keys is not a function

2 participants