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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user