From 547c218ddfffa8f85d5f4863914e0e9efa5b4dbe Mon Sep 17 00:00:00 2001 From: silent-reader-cn Date: Fri, 10 Jul 2026 09:57:00 +0800 Subject: [PATCH] fix: clear fallback smd media tail --- static/messages.js | 6 +++--- tests/test_smd_media_in_stream.py | 9 +++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/static/messages.js b/static/messages.js index 4858009bb..babe53df0 100644 --- a/static/messages.js +++ b/static/messages.js @@ -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; diff --git a/tests/test_smd_media_in_stream.py b/tests/test_smd_media_in_stream.py index 1d7e0c506..919265c9d 100644 --- a/tests/test_smd_media_in_stream.py +++ b/tests/test_smd_media_in_stream.py @@ -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