Fix infinite loop in parser when streaming with unclosed formatting markers#154
Fix infinite loop in parser when streaming with unclosed formatting markers#154
Conversation
… markers Co-authored-by: hustcc <7856674+hustcc@users.noreply.github.com>
|
@copilot 将 example 中的流式渲染案例,每次增量输出 50 字符改成 10,然后添加一个 GitHub action 将 example 构建出来部署到 sugar.sh 上,便于我访问链接测试。 参考:https://github.com/antvis/GPT-Vis/blob/main/.github/workflows/preview.yml |
Co-authored-by: hustcc <7856674+hustcc@users.noreply.github.com>
已完成以下修改 (commit 4f3c7b1):
该 workflow 会在 PR 修改 |
|
🎊 PR Preview 69b588a has been successfully built and deployed to https://antvis-T8-preview-pr-154.surge.sh 🕐 Build time: 0.012s 🤖 By surge-preview |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #154 +/- ##
==========================================
- Coverage 79.95% 79.77% -0.19%
==========================================
Files 78 78
Lines 1626 1656 +30
Branches 270 272 +2
==========================================
+ Hits 1300 1321 +21
- Misses 326 335 +9
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
@copilot 运行代码来看,浏览器还是卡住的。 |
Co-authored-by: hustcc <7856674+hustcc@users.noreply.github.com>

Summary
Problem: When streaming T8 syntax rendering (incrementally adding text), the browser would freeze due to infinite loops in the
parseTextWithFormattingfunction.Root Causes Found:
**,__,*) without closing pairs didn't advance currentIndexcurrentIndex + 2 < textLengthandcurrentIndex + 1 < textLength) were too restrictive, markers at positions near the end weren't checkedcurrentIndexbut boundary conditions prevented processing it, the fallback code found the marker at the same position and didn't advance, causing infinite loopSolutions Applied:
< textLengthto allow checking markers at the last positionscurrentIndexbut can't be processed, treat it as plain text and advance past itTesting:
Impact: This fix enables safe streaming rendering for real-time data visualization and AI-generated content scenarios.
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.