wtt-connect 0.2.31 → 0.2.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/wtt-client.js +10 -7
package/package.json
CHANGED
package/src/wtt-client.js
CHANGED
|
@@ -41,14 +41,17 @@ export class WTTClient {
|
|
|
41
41
|
}
|
|
42
42
|
log('info', 'WTT websocket connected');
|
|
43
43
|
await this.sendHeartbeat();
|
|
44
|
+
let heartbeatInFlight = false;
|
|
44
45
|
const heartbeat = setInterval(() => {
|
|
45
46
|
if (ws.readyState !== WebSocket.OPEN) return;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
ws.
|
|
51
|
-
}
|
|
47
|
+
if (heartbeatInFlight) return;
|
|
48
|
+
heartbeatInFlight = true;
|
|
49
|
+
this.sendHeartbeat().catch((err) => {
|
|
50
|
+
log('warn', 'WTT websocket heartbeat failed; reconnecting', { error: err?.message || err });
|
|
51
|
+
try { ws.close(); } catch {}
|
|
52
|
+
}).finally(() => {
|
|
53
|
+
heartbeatInFlight = false;
|
|
54
|
+
});
|
|
52
55
|
}, Math.max(5, this.config.heartbeatSeconds) * 1000);
|
|
53
56
|
await this.pollMissedMessages();
|
|
54
57
|
try {
|
|
@@ -138,7 +141,7 @@ export class WTTClient {
|
|
|
138
141
|
if (!this.ws || this.ws.readyState !== WebSocket.OPEN) return;
|
|
139
142
|
const runtime = this.runtimeInfoProvider ? this.runtimeInfoProvider() : null;
|
|
140
143
|
if (runtime) {
|
|
141
|
-
await this.
|
|
144
|
+
await this.action('heartbeat', { runtime }, Math.max(10000, this.config.heartbeatSeconds * 1000));
|
|
142
145
|
} else {
|
|
143
146
|
this.ws.send('ping');
|
|
144
147
|
}
|