Fix server hang: stop CTP reconnect storm and throttle live account polling.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-03 21:24:30 +08:00
parent d6776d2b8e
commit 9508d88938
5 changed files with 38 additions and 18 deletions
+6 -6
View File
@@ -270,10 +270,10 @@
posFastPollCount = 0;
posFastPollTimer = setInterval(function () {
pollPositions();
refreshCtpAccountQuick();
if (posFastPollCount % 3 === 0) refreshCtpAccountQuick();
posFastPollCount += 1;
if (posFastPollCount >= posFastPollMax) stopPosFastPoll();
}, 1000);
}, 2000);
}
function refreshCtpAccountQuick() {
@@ -328,8 +328,8 @@
if (connected) {
showCtpError('');
if (data.sync_state === 'syncing') {
posFastPollMax = Math.max(posFastPollMax, 240);
if (!posFastPollTimer) startPosFastPoll(240);
posFastPollMax = Math.max(posFastPollMax, 90);
if (!posFastPollTimer) startPosFastPoll(90);
}
} else if (!connecting && data.ctp_status && data.ctp_status.last_error) {
showCtpError(data.ctp_status.last_error);
@@ -714,7 +714,7 @@
showCtpError('');
refreshCtpAccountQuick();
pollPositions();
startPosFastPoll(180);
startPosFastPoll(60);
return d;
}
if ((st.login_cooldown_sec || 0) > 0 || d.cooldown) {
@@ -724,7 +724,7 @@
}
if (d.connecting || st.connecting) {
updateCtpBadge(false, true);
startPosFastPoll(180);
startPosFastPoll(60);
return waitForCtpConnected(70000).then(function (ok) {
if (!ok && d.error) showCtpError(d.error);
else if (!ok && st.last_error) showCtpError(st.last_error);