@dev-anywhere/relay 0.4.81 → 0.4.82

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.
@@ -3032,12 +3032,20 @@ function handleClientConnection(ws, registry, logger, chaos, voiceConfigStore, v
3032
3032
  closeRejectedClientProtocol(clientWs);
3033
3033
  }
3034
3034
  });
3035
- clientWs.on("close", () => {
3035
+ clientWs.on("close", (code, reason) => {
3036
3036
  registry.removeClientWs(clientWs);
3037
3037
  if (clientWs.clientId) {
3038
3038
  registry.unbindClientById(clientWs.clientId);
3039
3039
  }
3040
- logger.info({ clientId: clientWs.clientId }, "Client disconnected");
3040
+ logger.info(
3041
+ {
3042
+ clientId: clientWs.clientId,
3043
+ boundProxyId: clientWs.boundProxyId,
3044
+ code,
3045
+ reason: reason.toString() || void 0
3046
+ },
3047
+ "Client disconnected"
3048
+ );
3041
3049
  });
3042
3050
  clientWs.on("error", (err) => {
3043
3051
  logger.error({ err }, "Client WebSocket error");
@@ -3048,7 +3056,7 @@ function handleClientConnection(ws, registry, logger, chaos, voiceConfigStore, v
3048
3056
  function markAlive(ws) {
3049
3057
  ws.isAlive = true;
3050
3058
  }
3051
- function setupHeartbeat(wss, interval = 3e4) {
3059
+ function setupHeartbeat(wss, interval = 3e4, options = {}) {
3052
3060
  wss.on("connection", (ws) => {
3053
3061
  markAlive(ws);
3054
3062
  ws.on("pong", () => {
@@ -3059,6 +3067,13 @@ function setupHeartbeat(wss, interval = 3e4) {
3059
3067
  for (const ws of wss.clients) {
3060
3068
  const sock = ws;
3061
3069
  if (sock.isAlive === false) {
3070
+ options.logger?.warn(
3071
+ {
3072
+ peerType: options.peerType,
3073
+ ...options.describePeer?.(ws) ?? {}
3074
+ },
3075
+ "WebSocket heartbeat timeout"
3076
+ );
3062
3077
  sock.terminate();
3063
3078
  continue;
3064
3079
  }
@@ -4211,10 +4226,27 @@ function createRelayServer(options) {
4211
4226
  voiceTtsWss.on("connection", (ws) => {
4212
4227
  handleVoiceTtsConnection(ws, voiceConfigStore, logger, voiceProviders);
4213
4228
  });
4214
- const proxyHeartbeat = setupHeartbeat(proxyWss, heartbeatInterval);
4215
- const clientHeartbeat = setupHeartbeat(clientWss, heartbeatInterval);
4216
- const voiceAsrHeartbeat = setupHeartbeat(voiceAsrWss, heartbeatInterval);
4217
- const voiceTtsHeartbeat = setupHeartbeat(voiceTtsWss, heartbeatInterval);
4229
+ const proxyHeartbeat = setupHeartbeat(proxyWss, heartbeatInterval, {
4230
+ logger,
4231
+ peerType: "proxy",
4232
+ describePeer: (ws) => ({ proxyId: ws.proxyId })
4233
+ });
4234
+ const clientHeartbeat = setupHeartbeat(clientWss, heartbeatInterval, {
4235
+ logger,
4236
+ peerType: "client",
4237
+ describePeer: (ws) => ({
4238
+ clientId: ws.clientId,
4239
+ boundProxyId: ws.boundProxyId
4240
+ })
4241
+ });
4242
+ const voiceAsrHeartbeat = setupHeartbeat(voiceAsrWss, heartbeatInterval, {
4243
+ logger,
4244
+ peerType: "voice-asr"
4245
+ });
4246
+ const voiceTtsHeartbeat = setupHeartbeat(voiceTtsWss, heartbeatInterval, {
4247
+ logger,
4248
+ peerType: "voice-tts"
4249
+ });
4218
4250
  async function close() {
4219
4251
  clearInterval(proxyHeartbeat);
4220
4252
  clearInterval(clientHeartbeat);
@@ -4273,4 +4305,4 @@ export {
4273
4305
  parseRelayChaosFromEnv,
4274
4306
  createRelayServer
4275
4307
  };
4276
- //# sourceMappingURL=chunk-XJZ3HOPH.js.map
4308
+ //# sourceMappingURL=chunk-5B2OTBDL.js.map