@@ -68,6 +68,7 @@ export class ConvexYjsProvider extends ObservableV2<ProviderEvents> {
6868 private debounceTimer : ReturnType < typeof setTimeout > | null = null
6969 private maxWaitTimer : ReturnType < typeof setTimeout > | null = null
7070 private pushInFlight = false
71+ private pushInFlightPromise : Promise < void > = Promise . resolve ( )
7172 private awarenessTimer : ReturnType < typeof setTimeout > | null = null
7273 private awarenessInFlight = false
7374 private awarenessDirty = false
@@ -200,7 +201,7 @@ export class ConvexYjsProvider extends ObservableV2<ProviderEvents> {
200201
201202 private flushUpdates ( ) : Promise < void > {
202203 this . clearUpdateTimers ( )
203- if ( this . pushInFlight ) return Promise . resolve ( )
204+ if ( this . pushInFlight ) return this . pushInFlightPromise
204205 if ( this . pendingUpdates . length === 0 ) return Promise . resolve ( )
205206
206207 const merged =
@@ -210,7 +211,7 @@ export class ConvexYjsProvider extends ObservableV2<ProviderEvents> {
210211 this . pendingUpdates = [ ]
211212
212213 this . pushInFlight = true
213- return this . config
214+ this . pushInFlightPromise = this . config
214215 . pushUpdate ( {
215216 documentId : this . documentId ,
216217 update : uint8ToArrayBuffer ( merged ) ,
@@ -228,6 +229,7 @@ export class ConvexYjsProvider extends ObservableV2<ProviderEvents> {
228229 this . pushInFlight = false
229230 if ( this . pendingUpdates . length > 0 ) this . scheduleFlush ( )
230231 } )
232+ return this . pushInFlightPromise
231233 }
232234
233235 private scheduleFlush ( ) {
@@ -258,7 +260,7 @@ export class ConvexYjsProvider extends ObservableV2<ProviderEvents> {
258260 }
259261 }
260262
261- // -- Awareness debouncing --
263+ // -- Awareness throttling --
262264
263265 private handleAwarenessUpdate = (
264266 {
0 commit comments