避免abort后创建新的session

This commit is contained in:
2026-06-03 10:04:00 +08:00
parent 96e5d25518
commit 76d4b510f4
2 changed files with 20 additions and 2 deletions
+2
View File
@@ -505,6 +505,7 @@ export const buildChatRouter = (
const clientSessionId = requestContext.clientSessionId;
let streamClosed = false;
const abortController = new AbortController();
sessionBridge.registerAbortController(clientSessionId, abortController);
const handleClientClose = () => {
if (streamClosed || abortController.signal.aborted) {
return;
@@ -606,6 +607,7 @@ export const buildChatRouter = (
}
} finally {
await sessionBridge.releaseRuntimeSession(clientSessionId, binding.sessionId);
sessionBridge.deleteAbortController(clientSessionId);
streamClosed = true;
req.off("close", handleClientClose);
res.off("close", handleClientClose);