mirror of
https://github.com/nbd-wtf/nostr-tools.git
synced 2025-12-08 16:28:49 +00:00
only transform filters with enableReconnect() when we're actually reconnecting.
This commit is contained in:
@@ -159,12 +159,14 @@ export class AbstractRelay {
|
||||
}
|
||||
clearTimeout(this.connectionTimeoutHandle)
|
||||
this._connected = true
|
||||
|
||||
const isReconnection = this.reconnectAttempts > 0
|
||||
this.reconnectAttempts = 0
|
||||
|
||||
// resubscribe to all open subscriptions
|
||||
for (const sub of this.openSubs.values()) {
|
||||
sub.eosed = false
|
||||
if (typeof this.enableReconnect === 'function') {
|
||||
if (isReconnection && typeof this.enableReconnect === 'function') {
|
||||
sub.filters = this.enableReconnect(sub.filters)
|
||||
}
|
||||
sub.fire()
|
||||
@@ -206,14 +208,17 @@ export class AbstractRelay {
|
||||
private async waitForDummyReq() {
|
||||
return new Promise((resolve, _) => {
|
||||
// make a dummy request with expected empty eose reply
|
||||
// ["REQ", "_", {"ids":["aaaa...aaaa"]}]
|
||||
const sub = this.subscribe([{ ids: ['a'.repeat(64)] }], {
|
||||
oneose: () => {
|
||||
sub.close()
|
||||
resolve(true)
|
||||
// ["REQ", "_", {"ids":["aaaa...aaaa"], "limit": 0}]
|
||||
const sub = this.subscribe(
|
||||
[{ ids: ['aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'], limit: 0 }],
|
||||
{
|
||||
oneose: () => {
|
||||
sub.close()
|
||||
resolve(true)
|
||||
},
|
||||
eoseTimeout: this.pingTimeout + 1000,
|
||||
},
|
||||
eoseTimeout: this.pingTimeout + 1000,
|
||||
})
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
2
jsr.json
2
jsr.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nostr/tools",
|
||||
"version": "2.18.2",
|
||||
"version": "2.19.0",
|
||||
"exports": {
|
||||
".": "./index.ts",
|
||||
"./core": "./core.ts",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"type": "module",
|
||||
"name": "nostr-tools",
|
||||
"version": "2.18.2",
|
||||
"version": "2.19.0",
|
||||
"description": "Tools for making a Nostr client.",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
Reference in New Issue
Block a user