@unicitylabs/nostr-js-sdk 0.2.4 → 0.2.5

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.
@@ -6254,14 +6254,16 @@ class NostrClient {
6254
6254
  return;
6255
6255
  }
6256
6256
  // Send a subscription request as a ping (relays respond with EOSE)
6257
- // Using a unique subscription ID that we immediately close
6257
+ // Use a single fixed subscription ID per relay to avoid accumulating subscriptions
6258
+ // Note: limit:1 is used because some relays don't respond to limit:0
6258
6259
  try {
6259
- const pingSubId = `ping-${Date.now()}`;
6260
- const pingMessage = JSON.stringify(['REQ', pingSubId, { limit: 0 }]);
6261
- relay.socket.send(pingMessage);
6262
- // Immediately close the subscription
6260
+ const pingSubId = `ping`;
6261
+ // First close any existing ping subscription to ensure we don't accumulate
6263
6262
  const closeMessage = JSON.stringify(['CLOSE', pingSubId]);
6264
6263
  relay.socket.send(closeMessage);
6264
+ // Then send the new ping request (limit:1 ensures relay sends EOSE)
6265
+ const pingMessage = JSON.stringify(['REQ', pingSubId, { limit: 1 }]);
6266
+ relay.socket.send(pingMessage);
6265
6267
  }
6266
6268
  catch {
6267
6269
  // Send failed, connection likely dead