fix(extension): resolve 10-item limit truncation & WS zombie disconnection (v0.5.14)
This commit is contained in:
@@ -178,7 +178,8 @@ function setupMonitor() {
|
||||
ctx.logToFile(`[POLL#${pollCount}] alive`);
|
||||
}
|
||||
try {
|
||||
const allTraj = await ctx.sdk.ls.rawRPC('GetAllCascadeTrajectories', {});
|
||||
// Fix (v0.5.14): Reverted 100-limit DoS but restored descending: true with a safe limit of 30
|
||||
const allTraj = await ctx.sdk.ls.rawRPC('GetAllCascadeTrajectories', { limit: 30, descending: true });
|
||||
if (!allTraj?.trajectorySummaries) {
|
||||
if (pollCount <= 3) ctx.logToFile('[POLL] no trajectorySummaries');
|
||||
return;
|
||||
|
||||
@@ -124,6 +124,7 @@ export class WSBridgeClient {
|
||||
private heartbeatTimer: NodeJS.Timeout | null = null;
|
||||
private authTimer: NodeJS.Timeout | null = null;
|
||||
private lastPongTime: number = 0;
|
||||
private forceHeartbeatTimeoutIfNoPong = false;
|
||||
|
||||
// Message queue (survives reconnection)
|
||||
private messageQueue: WSMessage[] = [];
|
||||
@@ -440,6 +441,14 @@ export class WSBridgeClient {
|
||||
break;
|
||||
}
|
||||
|
||||
case 'pong': {
|
||||
// Sent by Hub in response to our 'heartbeat' JSON message
|
||||
// This is crucial for Browser-style WebSockets that don't expose native ping/pong
|
||||
this.forceHeartbeatTimeoutIfNoPong = true;
|
||||
this.lastPongTime = Date.now();
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
this.logFn(`[WS] Unknown message type: ${msg.type}`);
|
||||
}
|
||||
@@ -498,7 +507,8 @@ export class WSBridgeClient {
|
||||
this.heartbeatTimer = setInterval(() => {
|
||||
if (this.ws && this.connected) {
|
||||
// Check for zombie connection (no pong for 60s)
|
||||
if (Date.now() - this.lastPongTime > 60000) {
|
||||
const isNodeWs = (typeof this.ws.ping === 'function');
|
||||
if ((isNodeWs || this.forceHeartbeatTimeoutIfNoPong) && Date.now() - this.lastPongTime > 60000) {
|
||||
this.logFn('[WS] Heartbeat timeout — no pong received for 60s (zombie connection), terminating');
|
||||
if (this.ws) {
|
||||
try { this.ws.terminate(); } catch { try { this.ws.close(); } catch { } }
|
||||
|
||||
Reference in New Issue
Block a user