Commit 4b30782
fix: race condition in _loadPreview causing stale iframe overwrites
_togglePinUrl() calls _loadPreview(true) without awaiting it, so
multiple concurrent _loadPreview calls can interleave. When the
earlier call's getPreviewDetails() involves slow async I/O (e.g.
FileSystem.existsAsync for SVG files on Chrome's virtual filesystem),
a newer _loadPreview call can complete first and set the correct
iframe URL. The older call then resumes with stale previewDetails and
overwrites the iframe, breaking the live preview.
Add a generation counter so that after the await, a _loadPreview call
detects if a newer call was initiated and bails out, preventing stale
results from clobbering the current preview state.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>1 parent 0494d2b commit 4b30782
1 file changed
Lines changed: 6 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
545 | 545 | | |
546 | 546 | | |
547 | 547 | | |
548 | | - | |
| 548 | + | |
| 549 | + | |
549 | 550 | | |
550 | 551 | | |
551 | 552 | | |
| |||
795 | 796 | | |
796 | 797 | | |
797 | 798 | | |
| 799 | + | |
798 | 800 | | |
799 | 801 | | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
800 | 805 | | |
801 | 806 | | |
802 | 807 | | |
| |||
0 commit comments