fix: purge missing inflight sessions - #2129
Conversation
818865b to
dd543e4
Compare
SummaryRead the diff at PR head Code reference
for (const sid of Object.keys(INFLIGHT)) {
if (!sessionsById.has(sid)) {
// Session is absent from _allSessions — it was deleted / archived /
// filtered and can never stream again, so drop the entry.
delete INFLIGHT[sid];
if (typeof clearInflightState === 'function') clearInflightState(sid);
continue;
}
const s = sessionsById.get(sid);
if (!s.is_streaming) {
// Session exists but is not streaming — purge it.
delete INFLIGHT[sid];
if (typeof clearInflightState === 'function') clearInflightState(sid);
}
// Sessions that exist and are still streaming are preserved.
}DiagnosisThis matches the bug shape described in #2092 exactly. The original guard was One subtlety worth confirming: Test planThe new
The updated RecommendationLGTM. The change is surgical, the tests cover both regression cases, and the comment update on lines 246-253 explains the broadened scope clearly. CI should be green; no further work needed. |
6297443
fix: purge missing inflight sessions (closes nesquena#2092)
fix: purge missing inflight sessions (closes nesquena#2092)
fix: purge missing inflight sessions (closes nesquena#2092)
Thinking Path
INFLIGHTto track active streaming sessions in the browser._allSessionsand marked non-streaming._allSessions, so theirINFLIGHTentries were never visited as non-streaming and could accumulate indefinitely.INFLIGHTkeys and explicitly drop ids absent from the current session list while preserving still-streaming sessions.What Changed
_purgeStaleInflightEntries()instatic/sessions.jsto remove missing-from-list session ids.is_streaming: false.tests/test_inflight_purge_missing_sessions.pycovering:Why It Matters
Long-running browser tabs no longer keep ghost
INFLIGHTentries after sessions are deleted, archived, or filtered out of the current list. This keeps futureINFLIGHTiteration from seeing stale session ids.Verification
git diff --checknode --check static/sessions.jsenv -u HERMES_CONFIG_PATH /home/michael/.hermes/hermes-agent/venv/bin/python -m pytest tests/test_inflight_purge_missing_sessions.py tests/test_issue2066_stale_sidebar_spinner.py -q— 6 passedRisks / Follow-ups
Model Used
minimax/minimax-m2.7.Closes #2092