Mermaid-Chart / issue-tracker

Other
11 stars 2 forks source link

Cannot destructure property 'config' of 'undefined' error when sharing or exporting #111

Open schlessera opened 3 days ago

schlessera commented 3 days ago

Describe the bug Export and sharing as SVG is broken for a diagram with the following error:

MermaidError: Cannot destructure property 'config' of 'undefined' as it is undefined. addVertex (file:///prod/mermaid-pre-render-server/node_modules/.pnpm/@mermaid-js+mermaid-cli@11.4.0_patch_hash=taxes6pgqytvd5wk2gq6oq35qe_puppeteer@23.8.0_typescript@5.6.3_/node_modules/@mermaid-js/mermaid-cli/dist/index.html:1046:1345)

To Reproduce Go to the following public SVG diagram to see the error: https://www.mermaidchart.com/raw/61fb7f6a-9a7c-4eed-bd0c-ac0875eeca81?theme=light&version=v0.1&format=svg

Here's the diagram source:

---
config:
  layout: elk
  theme: base
  look: classic
---
graph TB
    subgraph Server
        EXT["External Sources"]
        IMP["Importers"]
        subgraph Data["Data Layer"]
            DM["Core Data Model"]
            DB[(WordPress DB)]
        end
        subgraph Core["Core Layer"]
            SDK["PHP SDK"]
            REST["REST API"]
            SDK --> REST
            DM --> SDK
        end
        subgraph WP["WordPress Integration"]
            GB["Gutenberg Blocks"]
            PAT["Block Patterns"]
            THEME["Sanctioned Theme"]
            GB --> THEME
            PAT --> THEME
        end
    end
    subgraph Client
        subgraph Frontend["Frontend Layer"]
            UI["User Interface"]
            CMS["Content Management"]
        end
    end
    VIS@{ icon: "fa:user", label: "Visitor"}
    MAN@{ icon: "fa:user", label: "Manager"}

    IMP --> DM
    EXT --> DM
    DM --> DB
    REST <--> UI
    REST <--> CMS
    GB --> SDK
    GB --> REST
    GB --> UI
    PAT --> SDK
    THEME --> REST
    UI --> VIS
    CMS --> MAN
    classDef core fill:#f9f,stroke:#333,stroke-width:2px
    classDef data fill:#bbf,stroke:#333,stroke-width:2px
    classDef wp fill:#bfb,stroke:#333,stroke-width:2px
    classDef front fill:#fbb,stroke:#333,stroke-width:2px
    classDef phase2 stroke-dasharray: 5 5
    class DM,IMP,DB,EXT data
    class SDK,REST core
    class GB,PAT,THEME wp
    class UI,CMS,VIS,MAN front
    class IMP,EXT phase2

Expected behavior SVG representation of the diagram.

Additional context Renders fine in the editor.

schlessera commented 3 days ago

I have pinpointed it to the layout engine config:

---
config:
  layout: elk
---

When I remove the layout: elk line in the config, the diagram renders (albeit in a layout I don't want). Seems like the elk layout works in the editor but breaks when exporting/sharing.