From 711807cb81f85408451b843e1a53e9616fd6df3b Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Sat, 1 Aug 2026 18:00:51 -0700 Subject: Keep sync snapshots under relay size limits, and say when they bounce MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Tonight's payments pushed the encrypted snapshot past strfry's 64KB maxEventSize and every publish after the first zap was silently refused — the other device just showed no history, with nothing logged anywhere. The relay's limit is raised to 256KB; client-side, movements older than the last 50 now drop their bolt11/preimage (~half a KB per ln-send) and the cap tightens to 200, and a refused snapshot publish logs the relay's reason. Co-Authored-By: Claude Fable 5 --- src/features/ark.js | 5 ++++- src/nostr.js | 9 ++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/features/ark.js b/src/features/ark.js index 1c0ad1b..ff0dd13 100644 --- a/src/features/ark.js +++ b/src/features/ark.js @@ -136,7 +136,10 @@ export function slimArkForSync(s) { actions: (s.actions || []) .filter((a) => a.step === 'done' && ['board', 'offboard', 'exit'].includes(a.type)) .map((a) => { const c = { ...a }; for (const k of HEAVY) delete c[k]; return c; }), - movements: (s.movements || []).slice(-300), + movements: (s.movements || []).slice(-200).map((m, i, arr) => + // Older rows only need to render a history line; the bolt11 (~400 chars + // each) and preimage are what pushed snapshots past relay size limits. + (arr.length - i <= 50 ? m : (({ invoice, preimage, ...rest }) => rest)(m))), gifts: s.gifts, }; } diff --git a/src/nostr.js b/src/nostr.js index 37bd62d..05ae723 100644 --- a/src/nostr.js +++ b/src/nostr.js @@ -213,7 +213,14 @@ export class NostrSync { const content = nip44.encrypt(JSON.stringify(stateObj), this.ck); evt = finalizeEvent({ kind: 30078, created_at: Math.floor(Date.now() / 1000), tags: [['d', dtag]], content }, this.sk); } catch { return; } - await Promise.allSettled(pool.publish(this.relays, evt)); + const results = await Promise.allSettled(pool.publish(this.relays, evt)); + // A refused snapshot means devices silently stop syncing — the failure + // that once hid behind "my other device shows no history". Say so. + results.forEach((r, i) => { + if (r.status === 'rejected') { + console.warn(`nostr: state snapshot (${evt.content.length}b) refused by ${this.relays[i]}:`, r.reason?.message || r.reason); + } + }); } // Deliver an encrypted DM (a locked gift's claim code) as a NIP-17 gift wrap -- cgit v1.2.3