fix: avoid serializing block diagram debug objects#7914
Conversation
✅ Deploy Preview for mermaid-js ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
🦋 Changeset detectedLatest commit: 3a6dfd1 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
@mermaid-js/examples
mermaid
@mermaid-js/layout-elk
@mermaid-js/layout-tidy-tree
@mermaid-js/mermaid-zenuml
@mermaid-js/parser
@mermaid-js/tiny
commit: |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #7914 +/- ##
============================================
- Coverage 67.78% 25.97% -41.81%
============================================
Files 429 193 -236
Lines 38648 14123 -24525
Branches 6380 1888 -4492
============================================
- Hits 26199 3669 -22530
- Misses 9675 10133 +458
+ Partials 2774 321 -2453
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
The latest updates on your projects. Learn more about Argos notifications ↗︎
|
|
All checks are passing, and the PR includes a regression test and a changeset. |
📑 Summary
Resolves #7907
This fixes a block diagram render crash caused by debug logging that attempted to serialize block layout objects with
JSON.stringify.In some environments, DOM nodes attached to block sizes can include extra enumerable properties, such as React-related properties, which may create circular references. When the block layout debug log tried to stringify those objects, rendering could fail with
TypeError: Converting circular structure to JSON.📏 Design Decisions
Instead of serializing the full block tree or full block size object, the debug output now logs only a safe summary of primitive layout values.
This keeps the existing layout behavior unchanged while avoiding serialization of DOM nodes or other non-serializable objects.
A regression test was added to verify that layout does not throw when a block size contains a non-serializable node.
📋 Tasks
Tests
corepack pnpm exec vitest run packages/mermaid/src/diagrams/block/layout.spec.tscorepack pnpm exec vitest run packages/mermaid/src/diagrams/blockgit diff --check