Intermittent issue with Mermaid Diagrams not getting rendered

Issue

It was found that mermaid diagrams are not getting rendered in the comment section. It appears to be an intermittent issue and gets resolved upon page refresh.

It has been reported multiple times internally and discussed in a Slack thread.

Steps to reproduce

Note: It's an intermittent issue with no clear steps to reproduce.

  1. Create a new issue
  2. Add a comment with the following content (enclosed them with ```mermaid)
sequenceDiagram
    User->>GitLab: GET /project/-/archive/master.zip
    GitLab->>User: 302 Found
    Note over User,GitLab: Location: https://cdn.com/project/-/archive/master.zip?token=secure-user-token
    User->>CDN: GET /project/-/archive/master.zip?token=secure-user-token
    alt object not in cache
      CDN->>GitLab: GET /project/-/archive/master.zip
      Note over CDN,GitLab: X-Gitlab-External-Storage-Token: secure-cdn-token<br/>X-Gitlab-Static-Object-Token: secure-user-token
      GitLab->>CDN: 200 OK
      CDN->>User: master.zip
    else object in cache
      CDN->>GitLab: GET /project/-/archive/master.zip
      Note over CDN,GitLab: X-Gitlab-External-Storage-Token: secure-cdn-token<br/>X-Gitlab-Static-Object-Token: secure-user-token<br/>If-None-Match: etag-value
      GitLab->>CDN: 304 Not Modified
      CDN->>User: master.zip
    end
graph LR; A-->C;
  1. Refresh the page until you find the comment is not rendered

PoC

image

Fix

TBD

Edited by Dheeraj Joshi