fix(messages): disable SSE (requires async workers), add polling fallback every 5s
Some checks are pending
NordaBiz Tests / Unit & Integration Tests (push) Waiting to run
NordaBiz Tests / E2E Tests (Playwright) (push) Blocked by required conditions
NordaBiz Tests / Smoke Tests (Production) (push) Blocked by required conditions
NordaBiz Tests / Send Failure Notification (push) Blocked by required conditions
Some checks are pending
NordaBiz Tests / Unit & Integration Tests (push) Waiting to run
NordaBiz Tests / E2E Tests (Playwright) (push) Blocked by required conditions
NordaBiz Tests / Smoke Tests (Production) (push) Blocked by required conditions
NordaBiz Tests / Send Failure Notification (push) Blocked by required conditions
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
7e60308d36
commit
f4bc150c0a
@ -1233,11 +1233,18 @@
|
||||
|
||||
var SSEClient = {
|
||||
connect: function () {
|
||||
// SSE disabled: requires async gunicorn workers (gevent/eventlet).
|
||||
// Using polling fallback until async workers are configured.
|
||||
console.info('SSE disabled — using polling fallback (5s interval)');
|
||||
SSEClient.startPollingFallback();
|
||||
return;
|
||||
|
||||
/* SSE code — enable when gunicorn has async workers:
|
||||
if (state.sse) {
|
||||
state.sse.close();
|
||||
}
|
||||
|
||||
state.sse = new EventSource('/api/messages/stream');
|
||||
*/
|
||||
|
||||
state.sse.addEventListener('connected', function () {
|
||||
state.reconnectDelay = 1000;
|
||||
@ -1460,6 +1467,35 @@
|
||||
}
|
||||
},
|
||||
|
||||
startPollingFallback: function () {
|
||||
// Poll for new messages every 5 seconds when SSE is unavailable
|
||||
if (state.pollingInterval) return;
|
||||
state.pollingInterval = setInterval(function () {
|
||||
if (!state.currentConversationId) return;
|
||||
var convId = state.currentConversationId;
|
||||
var msgs = state.messages[convId];
|
||||
var lastId = msgs && msgs.length ? msgs[msgs.length - 1].id : 0;
|
||||
api('/api/conversations/' + convId + '/messages?after_id=' + lastId)
|
||||
.then(function (data) {
|
||||
if (data.messages && data.messages.length > 0) {
|
||||
data.messages.forEach(function (msg) {
|
||||
if (!msgs.some(function (m) { return m.id === msg.id; })) {
|
||||
ChatView.appendMessage(msg);
|
||||
state.messages[convId].push(msg);
|
||||
}
|
||||
});
|
||||
// Update conversation list
|
||||
var lastMsg = data.messages[data.messages.length - 1];
|
||||
ConversationList.updateConversation(convId, {
|
||||
last_message: lastMsg,
|
||||
updated_at: lastMsg.created_at
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch(function () {});
|
||||
}, 5000);
|
||||
},
|
||||
|
||||
startHeartbeat: function () {
|
||||
state.heartbeatInterval = setInterval(function () {
|
||||
api('/api/messages/heartbeat', 'POST').catch(function () {});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user