# mermaid: Fix stack overflow when laying out deeply nested subgraphs \(\#58325\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/4e949a1cc3bad04069bf6438d23569de29a12175)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 4e949a1cc3bad04069bf6438d23569de29a12175

Requested commit: 4e949a1cc3bad04069bf6438d23569de29a12175

Commit: 4e949a1cc3bad04069bf6438d23569de29a12175

Tree: abe11f06f7c98fb2bff8ba912feba9f155acc879

Author: Smit Barmase

Committer: GitHub

## Message

```
mermaid: Fix stack overflow when laying out deeply nested subgraphs (#58325)

Closes FR-49

This PR fixes stack overflow in flowcharts with deeply nested subgraphs.
Rewrote recursive call to iterate with an explicit stack on heap. Added
test which reproduces the overflow.

We use our fork now, with patch on existing v0.4.0:
https://github.com/zed-industries/merman/commit/1c765dcca2ef5092fcde7bebe8374819563623ef

Release Notes:

- Fixed a crash in when rendering Mermaid diagram flowcharts with deeply
nested subgraphs.
```

## Parents

- [b077f41a9f26ae5ed7fadfea55a501d34afb25de](https://git.cafe/gitcafe/zed/commit/b077f41a9f26ae5ed7fadfea55a501d34afb25de?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/4e949a1cc3bad04069bf6438d23569de29a12175?format=markdown)
