fix(extension): resolve 10-item limit truncation & WS zombie disconnection (v0.5.14)
This commit is contained in:
@@ -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