Skip to content

Emit persistentIds snapshots so consumers can persist correctly - #16

Draft
cassiostp wants to merge 1 commit into
masterfrom
cs/emit-persistent-ids
Draft

Emit persistentIds snapshots so consumers can persist correctly#16
cassiostp wants to merge 1 commit into
masterfrom
cs/emit-persistent-ids

Conversation

@cassiostp

Copy link
Copy Markdown

The disk copy of persistentIds kept by electron-push-receiver only ever grows: this client clears its in-memory list when the MCS login response acks the ids (client.js, added in #6 back in 2018 as an explicitly partial fix), but nothing tells the consumer, so the two copies diverge and the disk copy accumulates without bound. Field impact: 35MB+ config.json files rewritten synchronously per notification and a 30MB LoginRequest uploaded on every connect (superhuman/desktop CLI-2311).

This emits a persistentIds snapshot (a copy, not the live array) on every mutation: both append sites, including ids recorded for reportable decryption errors which consumers previously never saw, and the login clear. The clear now checks LoginResponse.error first: an errored login did not process receivedPersistentId, so those ids are not acked and must be kept. A loginResponse event is emitted either way so consumers can measure login latency. The snapshot is emitted before ON_NOTIFICATION_RECEIVED so persistence completes before consumers act on the message.

Publish as 2.1.8. electron-push-receiver 2.2.0 (superhuman/electron-push-receiver PR to follow) consumes the new event; merge and publish this one first. Note: test/notification.test.js fails without a local keys.js (pre-existing on master, needs the template filled in); client.test.js covers the new behavior.

🤖 Generated with Claude Code

Consumers (electron-push-receiver) keep a disk copy of persistentIds
that only ever grows: the in-memory list clears when the MCS login
response acks the ids, but nothing tells the consumer, so the disk
copy diverges and accumulates without bound (35MB+ config files in
the field).

Emit a 'persistentIds' snapshot on every mutation: after each append
(including ids recorded for reportable decryption errors, which were
previously invisible to consumers) and after the login-response clear.
The clear now also checks LoginResponse.error: an errored login did
not process receivedPersistentId, so the ids are not acked and must
be kept. A 'loginResponse' event is emitted either way so consumers
can measure login latency.

The snapshot is emitted before ON_NOTIFICATION_RECEIVED so persistence
can complete before consumers act on the message, and it is a copy so
consumers cannot share the mutable internal array.
@cassiostp
cassiostp force-pushed the cs/emit-persistent-ids branch from 29d5ec3 to b42ddac Compare August 13, 2026 21:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant