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