Bugfix: Why did the preview flash/disappear and show black screens d...

Documentation for Sessions

🐛 Bugfix: Why did the preview flash/disappear and show black screens d...

Date: 2026-03-23
Time: 22:38:09 UTC
Session: gspace1-261.14
Agent: angular
Confidence: 96%
Status: ✅ Documented


📋 Decision Context

Question:

Why did the preview flash/disappear and show black screens during generation?

Task: S257: Preview stability


🎯 Decision Made

Chosen:

Three fixes: (1) Blob URL lifecycle — keep old blob alive until new one is ready (preview-server.service.ts), (2) Compilation gating — suppress VFS-triggered recompiles during active generation, trigger per-module via filesReadyForReview$ (preview.service.ts), (3) CDN retry — add retry logic + visible error for Angular compiler load failure (preview-server.service.ts).

Options Considered:


💭 Reasoning

Root cause chain: During progressive generation, each module writes 5-15 files to VFS. Each file write fires lastFileChange signal → triggers rebuildTrigger → 800ms debounce → compileRspack(). But modules arrive every 15-30s, so multiple compilation cycles overlap. In updateAssets(), the old blob URL was revoked BEFORE the new one was created (line 39-42), causing a blank iframe for 100-300ms. If the second compilation failed (race condition, empty assets), the revoked blob URL was never replaced → permanent black screen. CDN timeout was a separate path: if esm.sh was slow, the prerequisite script's await import() hung indefinitely with no error handling → black screen with no diagnostic.


📁 Files Involved


🔗 Related


Auto-generated by MCP Smart Consolidation