fix(chat): revert cancelGeneration-on-disconnect
req.on("close") was firing for healthy SSE connections in this
Node/Express setup, which cancelled the in-flight agent the client was
still listening to and made even msg #1 fail after a fresh reload.
Keep the beginGeneration (no dispose) change from the same commit —
that one's correct.
This commit is contained in:
@@ -560,15 +560,6 @@ export function registerChatRoutes(ctx: ApiRoutesContext, deps: ChatRouteDeps):
|
|||||||
// Handle client disconnect
|
// Handle client disconnect
|
||||||
req.on("close", () => {
|
req.on("close", () => {
|
||||||
unsubscribe();
|
unsubscribe();
|
||||||
// If the response hasn't been ended (i.e. the generation was still
|
|
||||||
// streaming when the browser disconnected — tab close, navigation,
|
|
||||||
// network drop), cancel the agent so it doesn't keep running with
|
|
||||||
// nobody listening. Otherwise the next request for this session sees a
|
|
||||||
// stale `activeGenerations` entry and races against the lingering
|
|
||||||
// agent for the same CLI session file.
|
|
||||||
if (!res.writableEnded) {
|
|
||||||
chatManager.cancelGeneration(sessionId);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Send heartbeat every 30s to keep connection alive
|
// Send heartbeat every 30s to keep connection alive
|
||||||
|
|||||||
Reference in New Issue
Block a user