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)
|
clearTimeout(this.connectionTimeoutHandle)
|
||||||
this._connected = true
|
this._connected = true
|
||||||
|
|
||||||
|
const isReconnection = this.reconnectAttempts > 0
|
||||||
this.reconnectAttempts = 0
|
this.reconnectAttempts = 0
|
||||||
|
|
||||||
// resubscribe to all open subscriptions
|
// resubscribe to all open subscriptions
|
||||||
for (const sub of this.openSubs.values()) {
|
for (const sub of this.openSubs.values()) {
|
||||||
sub.eosed = false
|
sub.eosed = false
|
||||||
if (typeof this.enableReconnect === 'function') {
|
if (isReconnection && typeof this.enableReconnect === 'function') {
|
||||||
sub.filters = this.enableReconnect(sub.filters)
|
sub.filters = this.enableReconnect(sub.filters)
|
||||||
}
|
}
|
||||||
sub.fire()
|
sub.fire()
|
||||||
@@ -206,14 +208,17 @@ export class AbstractRelay {
|
|||||||
private async waitForDummyReq() {
|
private async waitForDummyReq() {
|
||||||
return new Promise((resolve, _) => {
|
return new Promise((resolve, _) => {
|
||||||
// make a dummy request with expected empty eose reply
|
// make a dummy request with expected empty eose reply
|
||||||
// ["REQ", "_", {"ids":["aaaa...aaaa"]}]
|
// ["REQ", "_", {"ids":["aaaa...aaaa"], "limit": 0}]
|
||||||
const sub = this.subscribe([{ ids: ['a'.repeat(64)] }], {
|
const sub = this.subscribe(
|
||||||
|
[{ ids: ['aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'], limit: 0 }],
|
||||||
|
{
|
||||||
oneose: () => {
|
oneose: () => {
|
||||||
sub.close()
|
sub.close()
|
||||||
resolve(true)
|
resolve(true)
|
||||||
},
|
},
|
||||||
eoseTimeout: this.pingTimeout + 1000,
|
eoseTimeout: this.pingTimeout + 1000,
|
||||||
})
|
},
|
||||||
|
)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
2
jsr.json
2
jsr.json
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@nostr/tools",
|
"name": "@nostr/tools",
|
||||||
"version": "2.18.2",
|
"version": "2.19.0",
|
||||||
"exports": {
|
"exports": {
|
||||||
".": "./index.ts",
|
".": "./index.ts",
|
||||||
"./core": "./core.ts",
|
"./core": "./core.ts",
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"name": "nostr-tools",
|
"name": "nostr-tools",
|
||||||
"version": "2.18.2",
|
"version": "2.19.0",
|
||||||
"description": "Tools for making a Nostr client.",
|
"description": "Tools for making a Nostr client.",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
|||||||
Reference in New Issue
Block a user