fix(contacts): time-box mesh join and friend topic link at boot

Cap contacts hyperswarm join and _syncFriendTopicLinks so session startup cannot block forever.

Co-authored-by: Cursor <[email protected]>
This commit is contained in:
Raven Scott
2026-06-01 22:33:48 -04:00
co-authored by Cursor
parent 0a620d5341
commit d1944a556c
+11 -3
View File
@@ -480,13 +480,21 @@ class PearcordContacts extends EventEmitter {
this.emit('peer', { peerId, type: 'leave' })
})
})
await this.swarm.join(topicToBuffer(contactsTopic(this.userId)), {
const joinMs = Number(process.env.PEARCORD_MESH_JOIN_MS) || 8000
await Promise.race([
this.swarm.join(topicToBuffer(contactsTopic(this.userId)), {
server: true,
client: true
})
}),
new Promise((resolve) => setTimeout(resolve, joinMs))
])
await this._flushSwarm(3500)
this._meshJoined = true
await this._syncFriendTopicLinks()
const linkMs = Number(process.env.PEARCORD_CONTACTS_FRIEND_LINK_MS) || 8000
await Promise.race([
this._syncFriendTopicLinks(),
new Promise((resolve) => setTimeout(resolve, linkMs))
])
if (this._lastSelfPresence) {
await broadcastContactsGossip(this, RPC.PRESENCE_UPDATE, this._lastSelfPresence)
}