fix(mesh): skip gossip when RPC method missing and catch encode errors

Avoid unhandledRejection when pearcord-shared lacks USER_UPSERT (method 0).

Co-authored-by: Cursor <[email protected]>
This commit is contained in:
Raven Scott
2026-05-25 00:24:41 -04:00
co-authored by Cursor
parent 369e2374dd
commit 26e86d70e1
2 changed files with 11 additions and 3 deletions
+3 -2
View File
@@ -912,8 +912,9 @@ class PearcordGuild extends EventEmitter {
}
gossipUserUpsert (user) {
if (!user?.id) return
broadcastGossip(this, RPC.USER_UPSERT, user)
const method = RPC.USER_UPSERT
if (!user?.id || !method) return
void broadcastGossip(this, method, user).catch(() => {})
}
gossipProfileCosmetic (payload) {
+8 -1
View File
@@ -29,7 +29,14 @@ function attachGossipMesh (guild, conn) {
}
async function broadcastGossip (guild, method, payload) {
const buf = encodeRpc(method, b4a.from(JSON.stringify(payload)))
const m = Number(method)
if (!Number.isInteger(m) || m <= 0 || m > 255) return
let buf
try {
buf = encodeRpc(m, payload)
} catch {
return
}
const sessions = [...guild._channels.values()]
await Promise.all(
sessions.map(async (session) => {