go-gitea / gitea

Git with a cup of tea! Painless self-hosted all-in-one software development service, including Git hosting, code review, team collaboration, package registry and CI/CD
https://gitea.com
MIT License
45.24k stars 5.5k forks source link

Fix race condition in mermaid observer #32599

Open william-allspice opened 16 hours ago

william-allspice commented 16 hours ago

This Pull Request addresses a race condition in the updateIframeHeight function where it is sometimes called when the iframe is not fully loaded or accessible resulting in an alarming error message for the user.

Screenshot 2024-11-21 at 9 44 59 AM

I have reproduced this here: https://gitea.com/small_world/MermaidTest/src/branch/main/

Please note: This error is reproducible but it happens intermittently.

To address this we:

  1. Add defensive programming within the updateIframeHeight function
  2. Delay instantiating the intersection observer until the iframe has loaded