1+ import { safeRandomUUID } from '@tanstack/db-sqlite-persistence-core'
12import type {
23 ApplyLocalMutationsResponse ,
34 PersistedCollectionCoordinator ,
@@ -118,7 +119,7 @@ export type BrowserCollectionCoordinatorOptions = {
118119// ---------------------------------------------------------------------------
119120
120121export class BrowserCollectionCoordinator implements PersistedCollectionCoordinator {
121- private readonly nodeId = crypto . randomUUID ( )
122+ private readonly nodeId = safeRandomUUID ( )
122123 private readonly dbName : string
123124 private adapter : AdapterWithPullSince | null
124125 private readonly channel : BroadcastChannel
@@ -205,7 +206,7 @@ export class BrowserCollectionCoordinator implements PersistedCollectionCoordina
205206 error ?: string
206207 } > ( collectionId , {
207208 type : `rpc:ensureRemoteSubset:req` ,
208- rpcId : crypto . randomUUID ( ) ,
209+ rpcId : safeRandomUUID ( ) ,
209210 options,
210211 } )
211212
@@ -233,7 +234,7 @@ export class BrowserCollectionCoordinator implements PersistedCollectionCoordina
233234 error ?: string
234235 } > ( collectionId , {
235236 type : `rpc:ensurePersistedIndex:req` ,
236- rpcId : crypto . randomUUID ( ) ,
237+ rpcId : safeRandomUUID ( ) ,
237238 signature,
238239 spec,
239240 } )
@@ -252,16 +253,16 @@ export class BrowserCollectionCoordinator implements PersistedCollectionCoordina
252253 if ( this . isLeader ( collectionId ) ) {
253254 return this . handleApplyLocalMutations ( collectionId , {
254255 type : `rpc:applyLocalMutations:req` ,
255- rpcId : crypto . randomUUID ( ) ,
256- envelopeId : crypto . randomUUID ( ) ,
256+ rpcId : safeRandomUUID ( ) ,
257+ envelopeId : safeRandomUUID ( ) ,
257258 mutations,
258259 } )
259260 }
260261
261262 return this . sendRPC < ApplyLocalMutationsResponse > ( collectionId , {
262263 type : `rpc:applyLocalMutations:req` ,
263- rpcId : crypto . randomUUID ( ) ,
264- envelopeId : crypto . randomUUID ( ) ,
264+ rpcId : safeRandomUUID ( ) ,
265+ envelopeId : safeRandomUUID ( ) ,
265266 mutations,
266267 } )
267268 }
@@ -273,14 +274,14 @@ export class BrowserCollectionCoordinator implements PersistedCollectionCoordina
273274 if ( this . isLeader ( collectionId ) ) {
274275 return this . handlePullSince ( collectionId , {
275276 type : `rpc:pullSince:req` ,
276- rpcId : crypto . randomUUID ( ) ,
277+ rpcId : safeRandomUUID ( ) ,
277278 fromRowVersion,
278279 } )
279280 }
280281
281282 return this . sendRPC < PullSinceResponse > ( collectionId , {
282283 type : `rpc:pullSince:req` ,
283- rpcId : crypto . randomUUID ( ) ,
284+ rpcId : safeRandomUUID ( ) ,
284285 fromRowVersion,
285286 } )
286287 }
@@ -663,7 +664,7 @@ export class BrowserCollectionCoordinator implements PersistedCollectionCoordina
663664
664665 // Build and apply the persisted transaction
665666 const tx = {
666- txId : crypto . randomUUID ( ) ,
667+ txId : safeRandomUUID ( ) ,
667668 term,
668669 seq,
669670 rowVersion,
0 commit comments