fix(keysync): silence expected RLS rejections during best-effort backfill
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"$schema": "https://schema.tauri.app/config/2",
|
"$schema": "https://schema.tauri.app/config/2",
|
||||||
"productName": "ChatApp",
|
"productName": "ChatApp",
|
||||||
"version": "0.4.2",
|
"version": "0.4.3",
|
||||||
"identifier": "com.meinname.chatapp",
|
"identifier": "com.meinname.chatapp",
|
||||||
"build": {
|
"build": {
|
||||||
"beforeDevCommand": "pnpm vite:dev",
|
"beforeDevCommand": "pnpm vite:dev",
|
||||||
|
|||||||
@@ -164,14 +164,25 @@ async function syncOneConversationGaps(ctx: SyncCtx, convId: string): Promise<vo
|
|||||||
try {
|
try {
|
||||||
await shareConvKeyToDevice(supabase, convId, dev.id, pgHexToBytes(dev.public_key), ownCtx);
|
await shareConvKeyToDevice(supabase, convId, dev.id, pgHexToBytes(dev.public_key), ownCtx);
|
||||||
} catch (err: unknown) {
|
} catch (err: unknown) {
|
||||||
// Most common: this device hasn't been wrapped for us yet either, so
|
// Backfill is best-effort. Common silent failures:
|
||||||
// tryGetConvKey couldn't unwrap. Another peer with the key will fill
|
// - This device hasn't been wrapped for us yet either, so
|
||||||
// the gap when they hit syncAllExistingGaps.
|
// tryGetConvKey couldn't unwrap (another peer will fill the gap).
|
||||||
console.warn('keySync: shareConvKeyToDevice gap-fill failed', {
|
// - RLS rejects because the recipient's owner is a pending (not-yet
|
||||||
convId,
|
// accepted) DM member, or has been removed from the conv.
|
||||||
recipient: dev.id,
|
// Any of these are recoverable — log only at debug level.
|
||||||
err,
|
const msg = err instanceof Error ? err.message : String(err);
|
||||||
});
|
const isExpected =
|
||||||
|
msg.includes('does not have it yet') ||
|
||||||
|
msg.includes('row-level security') ||
|
||||||
|
msg.includes('403') ||
|
||||||
|
msg.includes('Forbidden');
|
||||||
|
if (!isExpected) {
|
||||||
|
console.warn('keySync: shareConvKeyToDevice gap-fill failed', {
|
||||||
|
convId,
|
||||||
|
recipient: dev.id,
|
||||||
|
err,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user