fix: 🐛

This commit is contained in:
codytseng
2025-03-12 22:33:46 +08:00
parent ddd4d998f4
commit 9285ecca3d

View File

@@ -17,7 +17,7 @@ import {
SimplePool, SimplePool,
VerifiedEvent VerifiedEvent
} from 'nostr-tools' } from 'nostr-tools'
import { AbstractRelay } from 'nostr-tools/abstract-relay' import { AbstractRelay, Subscription } from 'nostr-tools/abstract-relay'
import indexedDb from './indexed-db.service' import indexedDb from './indexed-db.service'
type TTimelineRef = [string, number] type TTimelineRef = [string, number]
@@ -305,14 +305,15 @@ class ClientService extends EventTarget {
let eosed = false let eosed = false
let closedCount = 0 let closedCount = 0
const closeReasons: string[] = [] const closeReasons: string[] = []
const subPromises = relays.map(async (url) => { const subPromises: Promise<Subscription>[] = []
const relay = await this.pool.ensureRelay(url) relays.forEach((url) => {
let hasAuthed = false let hasAuthed = false
return startSub() subPromises.push(startSub())
function startSub() { async function startSub() {
startedCount++ startedCount++
const relay = await that.pool.ensureRelay(url)
return relay.subscribe(filters, { return relay.subscribe(filters, {
receivedEvent: (relay, id) => { receivedEvent: (relay, id) => {
that.trackEventSeenOn(id, relay) that.trackEventSeenOn(id, relay)
@@ -358,7 +359,7 @@ class ClientService extends EventTarget {
.then(() => { .then(() => {
hasAuthed = true hasAuthed = true
if (!eosed) { if (!eosed) {
startSub() subPromises.push(startSub())
} }
}) })
.catch(() => { .catch(() => {