···121121122122 // and also send sync actions (server is always a sync partner)
123123 if (req.dat.requestSync) {
124124- const actions = realm.buildSyncDelta(clocks)
124124+ const actions = realm.buildSyncDelta(req.dat.clocks)
125125 if (actions.length) {
126126- putSocket(ws, actions)
126126+ putSocket(ws, actions)
127127 }
128128 }
129129}
+2-1
src/realm/server/realm.ts
···239239 * @returns array of actions the peer has not seen
240240 */
241241 buildSyncDelta(clocks: PeerClocks): RealmAction[] {
242242- const entries = Object.entries(clocks)
243242 const schema = jsonCodec(actionSchema)
244243244244+ // a null clock is the same as no clock
245245+ const entries = Object.entries(clocks).filter(([_, v]) => !!v)
245246 if (entries.length === 0) {
246247 const stmt = this.#database.prepare(`SELECT action FROM action ORDER BY clock ASC`)
247248 const rows = stmt.all()