fix: clear fallback smd media tail

This commit is contained in:
silent-reader-cn
2026-07-10 09:57:00 +08:00
committed by nesquena-hermes
parent ca3a1ac04d
commit 547c218ddf
2 changed files with 12 additions and 3 deletions
+3 -3
View File
@@ -4094,9 +4094,9 @@ function attachLiveStream(activeSid, streamId, uploaded=[], options={}){
_smdParser=null;
_smdWrittenLen=0;
_smdWrittenText='';
// Clear the per-parser MEDIA tail buffer — any incomplete MEDIA
// prefix the parser was holding is no longer relevant.
if(typeof _smdMediaTailClear==='function') _smdMediaTailClear(null);
// Clear the fallback MEDIA tail buffer too; fallback chunks are keyed
// by __SMD_PARSER_FALLBACK, not null.
if(typeof _smdMediaTailClear==='function') _smdMediaTailClear(__SMD_PARSER_FALLBACK);
}
function _scheduleStreamingKatex(){
if(_streamingKatexTimer) return;
+9
View File
@@ -247,6 +247,15 @@ class TestSmdMediaInStream(unittest.TestCase):
"concurrent streams don't cross-pollinate",
)
def test_smd_end_parser_clears_fallback_media_tail(self):
# Greptile re-review: parserFor falls back to __SMD_PARSER_FALLBACK,
# so stream-end cleanup must clear that sentinel key, not null.
idx = MESSAGES_JS.index("function _smdEndParser")
block = MESSAGES_JS[idx:idx + 1200]
self.assertIn("_smdMediaTailClear(_smdParser)", block)
self.assertIn("_smdMediaTailClear(__SMD_PARSER_FALLBACK)", block)
self.assertNotIn("_smdMediaTailClear(null)", block)
if __name__ == "__main__":
import unittest