@electric-sql/client 1.4.1 → 1.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@electric-sql/client",
3
3
  "description": "Postgres everywhere - your data, in sync, wherever you need it.",
4
- "version": "1.4.1",
4
+ "version": "1.4.2",
5
5
  "author": "ElectricSQL team and contributors.",
6
6
  "bugs": {
7
7
  "url": "https://github.com/electric-sql/electric/issues"
package/src/client.ts CHANGED
@@ -538,7 +538,7 @@ export class ShapeStream<T extends Row<unknown> = Row>
538
538
  readonly #messageParser: MessageParser<T>
539
539
 
540
540
  readonly #subscribers = new Map<
541
- number,
541
+ object,
542
542
  [
543
543
  (messages: Message<T>[]) => MaybePromise<void>,
544
544
  ((error: Error) => void) | undefined,
@@ -1161,8 +1161,10 @@ export class ShapeStream<T extends Row<unknown> = Row>
1161
1161
  const currentCursor = this.#liveCacheBuster
1162
1162
 
1163
1163
  if (currentCursor === this.#lastSeenCursor) {
1164
- // Same cursor = still replaying cached responses
1165
- // Suppress this up-to-date notification
1164
+ // Same cursor as previous session - suppress this up-to-date notification.
1165
+ // Exit replay mode after first suppression to ensure we don't get stuck
1166
+ // if CDN keeps returning the same cursor indefinitely.
1167
+ this.#lastSeenCursor = undefined
1166
1168
  return
1167
1169
  }
1168
1170
  }
@@ -1393,7 +1395,7 @@ export class ShapeStream<T extends Row<unknown> = Row>
1393
1395
  callback: (messages: Message<T>[]) => MaybePromise<void>,
1394
1396
  onError: (error: Error) => void = () => {}
1395
1397
  ) {
1396
- const subscriptionId = Math.random()
1398
+ const subscriptionId = {}
1397
1399
 
1398
1400
  this.#subscribers.set(subscriptionId, [callback, onError])
1399
1401
  if (!this.#started) this.#start()
package/src/shape.ts CHANGED
@@ -51,7 +51,7 @@ export class Shape<T extends Row<unknown> = Row> {
51
51
  readonly stream: ShapeStreamInterface<T>
52
52
 
53
53
  readonly #data: ShapeData<T> = new Map()
54
- readonly #subscribers = new Map<number, ShapeChangedCallback<T>>()
54
+ readonly #subscribers = new Map<object, ShapeChangedCallback<T>>()
55
55
  readonly #insertedKeys = new Set<string>()
56
56
  readonly #requestedSubSnapshots = new Set<string>()
57
57
  #reexecuteSnapshotsPending = false
@@ -149,7 +149,7 @@ export class Shape<T extends Row<unknown> = Row> {
149
149
  }
150
150
 
151
151
  subscribe(callback: ShapeChangedCallback<T>): () => void {
152
- const subscriptionId = Math.random()
152
+ const subscriptionId = {}
153
153
 
154
154
  this.#subscribers.set(subscriptionId, callback)
155
155