The reconnect loop does not reproduce; log who falls behind
Measured against a session streaming 20 events a second. Reopening one with an anchor 1,800 events back connects 87-119 events behind, under CATCH_UP_LIMIT's 200 -- the restore is two requests now, the opening page and one span covering the whole distance to the anchor, where the report was written against a restore that took thirteen. Three provocations, no repeat connection between them: that reopen, twenty seconds backgrounded while 415 events were produced, and a reset forced by dropping the limit to 5, where the app cleared, refilled and carried on without reconnecting. So the TODO entry goes. What stays is the instrument that answered it: every SSE subscriber now logs at debug the cursor it arrived with and whether it was continued or reset, since nothing else could say. The app sees a window arrive and cannot tell how far it had fallen. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
45e631ab96
commit
74110b4d72
3 files changed
+31
-14
No files matched your search
+12
-1
@@ -1788,9 +1788,20 @@ async fn stream_session(
|
||||
/// and local; revisit if daily use produces transcripts where this shows
|
||||
/// (phase 6 territory).
|
||||
async fn send_backlog(transcript: &Path, last: &mut u64, tx: &mpsc::Sender<SseEvent>) -> bool {
|
||||
let cursor = *last;
|
||||
let entries = match catch_up(transcript, *last, CATCH_UP_LIMIT) {
|
||||
Ok(CatchUp::Continue(entries)) => entries,
|
||||
Ok(CatchUp::Continue(entries)) => {
|
||||
// The pair of them at debug, because "was this subscriber reset,
|
||||
// and how far behind was it" is a question about a phone that
|
||||
// nothing else here can answer -- the app sees a window arrive
|
||||
// and cannot tell how far it had fallen, and a reset is the one
|
||||
// thing that makes its screen jump. `RUST_LOG=ai_server=debug`,
|
||||
// beside the transcript pages.
|
||||
tracing::debug!(cursor, sent = entries.len(), "stream backlog: continue");
|
||||
entries
|
||||
}
|
||||
Ok(CatchUp::Restart(entries)) => {
|
||||
tracing::debug!(cursor, sent = entries.len(), "stream backlog: reset");
|
||||
if tx.send(SseEvent::default().event("reset")).await.is_err() {
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user