Commit 739c9f8
committed
fix: sometimes the html live doc goes into an inconsistant state
1. Fixed BaseServer.remove() Bug (BaseServer.js:149)
Before: Used lookup result as key for deletion
After: Correctly uses the key string returned by _documentKey()
This fix ensures LiveHTMLDocuments are actually removed from the cache when
closed, preventing memory leaks and stale references.
2. Fixed _markText() Function (HTMLInstrumentation.js:823-847) ✩ PRIMARY FIX
Key change: Now detects when an editor has no marks and allows marking even when fullBuild = false
The logic now:
- Checks if the editor has any existing tagID marks
- Allows marking if: DOM is a full build OR editor has no marks
- Still refuses to re-mark if editor already has marks and DOM is stale (preserves safety)
This solves the core issue where switching editor panes or reopening documents would
leave the new editor without marks.
3. Added Defensive Fallback (HTMLInstrumentation.js:758-769)
Added a safety net that:
- Detects when markCache is empty but DOM has nodes
- Automatically forces re-marking if this happens
- Logs a warning so we know it triggered
How This Fixes the Issue
The error "couldn't find existing mark for tagID" occurred because:
1. Document edited -> cache has fullBuild = false
2. User switches panes -> new editor has NO marks
3. Old _markText() refused to mark the new editor
4. generateInstrumentedHTML() tried to use non-existent marks -> ERROR
Now:
- _markText() detects the editor has no marks and marks it anyway (even with fullBuild = false)
- If marks are somehow still missing, the defensive fallback catches it
- BaseServer properly cleans up old documents1 parent 1bf3852 commit 739c9f8
File tree
2 files changed
+27
-3
lines changed- src/LiveDevelopment
- MultiBrowserImpl/language
- Servers
2 files changed
+27
-3
lines changedLines changed: 25 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
754 | 754 | | |
755 | 755 | | |
756 | 756 | | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
757 | 770 | | |
758 | 771 | | |
759 | 772 | | |
| |||
827 | 840 | | |
828 | 841 | | |
829 | 842 | | |
830 | | - | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
831 | 855 | | |
832 | 856 | | |
833 | 857 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
146 | 146 | | |
147 | 147 | | |
148 | 148 | | |
149 | | - | |
| 149 | + | |
150 | 150 | | |
151 | | - | |
| 151 | + | |
152 | 152 | | |
153 | 153 | | |
154 | 154 | | |
| |||
0 commit comments