Support rendering in Web Workers and Cloudflare Workers
Author: miantiao-meCreated Sep 7, 2026Updated Sep 18, 2026
[email protected] fails when rendering ELK-based diagrams inside a browser Web Worker:
TypeError: Cannot set property self of #<WorkerGlobalScope> which has only a getterFlowchart, State, Class, and ER diagrams trigger the error, while Sequence and XY Charts render successfully.
The issue appears to come from ensureElk() deleting and restoring globalThis.self, which is read-only in WorkerGlobalScope.
It would be helpful to:
- Support rendering in browser Web Workers;
- Ensure compatibility with Cloudflare Workers;
- Add tests for both Worker environments.
Source: lukilabs/beautiful-mermaid