fix: clear usage interval in finally so it cannot leak on send failure (#25478)
getChatEventEmitter starts a setInterval emitting a `usage` socket event every second; clearInterval ran only after sendMessageSocket resolved, so any throw/reject left the interval firing for the page lifetime. Each failed send added another orphaned interval, inflating server-side usage accounting and growing CPU/memory over a session. Wrap the send in try/finally so the interval is always cleared, on both the happy path and any thrown/rejected path. The exception still propagates unchanged. Fixes #25465 Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
6f0277db52
commit
e2502ec80f
1 file changed
+3
-1
@@ -2159,6 +2159,7 @@
|
|||||||
if (primaryModel && primaryResponseMessageId) {
|
if (primaryModel && primaryResponseMessageId) {
|
||||||
const chatEventEmitter = await getChatEventEmitter(primaryModel.id, _chatId);
|
const chatEventEmitter = await getChatEventEmitter(primaryModel.id, _chatId);
|
||||||
|
|
||||||
|
try {
|
||||||
scrollToBottom();
|
scrollToBottom();
|
||||||
await sendMessageSocket(
|
await sendMessageSocket(
|
||||||
primaryModel,
|
primaryModel,
|
||||||
@@ -2173,9 +2174,10 @@
|
|||||||
regenerationPrompt
|
regenerationPrompt
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
} finally {
|
||||||
if (chatEventEmitter) clearInterval(chatEventEmitter);
|
if (chatEventEmitter) clearInterval(chatEventEmitter);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const getFeatures = () => {
|
const getFeatures = () => {
|
||||||
|
|||||||
Reference in new issue
Block a user