Skip to content

Fix Mermaid.js race condition in architecture diagrams plugin - #301

Merged
makr-code merged 2 commits into
developfrom
copilot/fix-mermaid-library-loading-error
Jan 9, 2026
Merged

makr-code merged 2 commits into
developfrom
copilot/fix-mermaid-library-loading-error

Conversation

Copilot AI commented Jan 8, 2026 •

Copy link
Copy Markdown
Contributor

WordPress architecture plugin fails with "Error: Failed to load Mermaid library" due to script loading timing issue.

Root Cause

Mermaid.js loads in footer via CDN while plugin JS also loads in footer and initializes on $(document).ready(). Race condition occurs when ready fires before CDN script completes.

Changes

Script Loading Order (themisdb-architecture-diagrams.php)

// Before: footer loading creates race condition
wp_enqueue_script('mermaid-js', $cdn_url, array(), '10.0.0', true);

// After: header loading guarantees availability
wp_enqueue_script('mermaid-js', $cdn_url, array(), '10.0.0', false);

Defensive Improvements (architecture-diagrams.js)

  • Timeout extended 5s → 10s for slow CDN responses
  • Error messages now indicate network/blocker issues
  • Console logging added for load diagnostics

Version → 1.0.2

Original prompt

ich bekomme beim laden des wordpress architexture plugin den Fehler "Error: Failed to load Mermaid library. Please refresh the page." angezeigt


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI self-assigned this Jan 8, 2026
Copilot AI changed the title [WIP] Fix error loading Mermaid library in WordPress plugin Fix Mermaid.js race condition in architecture diagrams plugin Jan 8, 2026
Copilot AI requested a review from makr-code January 8, 2026 21:49
@makr-code
makr-code marked this pull request as ready for review January 9, 2026 05:28
@makr-code
makr-code merged commit 2b8f4fb into develop Jan 9, 2026
@makr-code makr-code added this to the v1.0.2 milestone Mar 11, 2026
Copilot AI added a commit that referenced this pull request Jun 30, 2026
… and RoPE #307

Stub #301 Remediation - Timeseries Metadata Endpoints:
- handleAggregatesGet(): Replace hardcoded aggregates with real backend queries
  * Uses injected aggregates_fn_ provider if available
  * Falls back to ContinuousAggregateManager::listAggregates()
  * Final fallback to built-in defaults for backward compatibility
  * Adds tracing to track data source

- handleRetentionGet(): Replace empty policies with real retention data
  * Uses injected retentions_fn_ provider if available
  * Falls back to legacy retentionPoliciesFn_ for compatibility
  * Falls back to storage-based config lookup
  * Always appends TSStore's late-arrival window if configured
  * Adds tracing to track policy source

Stub #307 Remediation - RoPE Statistics:
- handleStatsGet(): Replace placeholder stats with real rotation metrics
  * Queries VectorIndexManager::getRotaryEmbeddingStats()
  * Returns rotation_count (total rotations performed)
  * Returns relational_rotation_count (for knowledge graphs)
  * Returns avg_rotation_latency_ms (converted from microseconds)
  * Returns status (available/unavailable)
  * Gracefully handles case when RoPE metrics unavailable

Tests (stub_remediation_test.cpp):
- TimeSeriesAggregatesWithProvider: Verify real aggregates returned
- TimeSeriesRetentionWithProvider: Verify real retention policies
- TimeSeriesAggregatesDefaultFallback: Verify backward compatibility
- RopeStatsWithRealMetrics: Verify real rotation metrics returned
- RopeStatsDisabledReturnsNoMetrics: Verify graceful disabled handling
- RopeStatsIncludesConfiguration: Verify config data included

All changes maintain backward compatibility and add tracing for debugging.
No breaking changes - existing tests should continue to pass.

Co-authored-by: Copilot <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants