Fix guild joinMesh flush so EPIPE does not abort guild open.

Stop awaiting swarm.join, swallow flush rejections, and honor skip-flush env for faster opens.

Co-authored-by: Cursor <[email protected]>
This commit is contained in:
Raven Scott
2026-05-23 13:02:39 -04:00
co-authored by Cursor
parent 02e5e43cc9
commit 11da523a6e
+10 -5
View File
@@ -901,19 +901,24 @@ class PearcordGuild extends EventEmitter {
this.emit('peer', { peerId, type: 'leave' })
})
})
await this.swarm.join(topic, { server: true, client: true })
this.swarm.join(topic, { server: true, client: true })
const flushMs = Number(
opts.flushMs ??
process.env.PEARCORD_GUILD_SWARM_FLUSH_MS ??
process.env.PEARCORD_SWARM_FLUSH_MS ??
2500
)
if (this.swarm.flush) {
const skipFlush =
opts.skipFlush === true || process.env.PEARCORD_GUILD_JOIN_SKIP_FLUSH === '1'
if (this.swarm.flush && !skipFlush) {
let flushed = false
await Promise.race([
this.swarm.flush().then(() => {
flushed = true
}),
this.swarm.flush().then(
() => {
flushed = true
},
() => {}
),
new Promise((resolve) => setTimeout(resolve, flushMs))
])
if (!flushed) {