@@ -366,6 +366,8 @@ export type SharedLogOptions<
366366 syncronizer ?: SynchronizerConstructor < R > ;
367367 timeUntilRoleMaturity ?: number ;
368368 waitForReplicatorTimeout ?: number ;
369+ waitForReplicatorRequestIntervalMs ?: number ;
370+ waitForReplicatorRequestMaxAttempts ?: number ;
369371 waitForPruneDelay ?: number ;
370372 distributionDebounceTime ?: number ;
371373 compatibility ?: number ;
@@ -376,6 +378,8 @@ export type SharedLogOptions<
376378export const DEFAULT_MIN_REPLICAS = 2 ;
377379export const WAIT_FOR_REPLICATOR_TIMEOUT = 9000 ;
378380export const WAIT_FOR_ROLE_MATURITY = 5000 ;
381+ export const WAIT_FOR_REPLICATOR_REQUEST_INTERVAL = 1000 ;
382+ export const WAIT_FOR_REPLICATOR_REQUEST_MIN_ATTEMPTS = 3 ;
379383// TODO(prune): Investigate if/when a non-zero prune delay is required for correctness
380384// (e.g. responsibility/replication-info message reordering in multi-peer scenarios).
381385// Prefer making pruning robust without timing-based heuristics.
@@ -564,6 +568,8 @@ export class SharedLog<
564568
565569 timeUntilRoleMaturity ! : number ;
566570 waitForReplicatorTimeout ! : number ;
571+ waitForReplicatorRequestIntervalMs ! : number ;
572+ waitForReplicatorRequestMaxAttempts ?: number ;
567573 waitForPruneDelay ! : number ;
568574 distributionDebounceTime ! : number ;
569575
@@ -1903,12 +1909,31 @@ export class SharedLog<
19031909 options ?. timeUntilRoleMaturity ?? WAIT_FOR_ROLE_MATURITY ;
19041910 this . waitForReplicatorTimeout =
19051911 options ?. waitForReplicatorTimeout ?? WAIT_FOR_REPLICATOR_TIMEOUT ;
1912+ this . waitForReplicatorRequestIntervalMs =
1913+ options ?. waitForReplicatorRequestIntervalMs ??
1914+ WAIT_FOR_REPLICATOR_REQUEST_INTERVAL ;
1915+ this . waitForReplicatorRequestMaxAttempts =
1916+ options ?. waitForReplicatorRequestMaxAttempts ;
19061917 this . waitForPruneDelay = options ?. waitForPruneDelay ?? WAIT_FOR_PRUNE_DELAY ;
19071918
19081919 if ( this . waitForReplicatorTimeout < this . timeUntilRoleMaturity ) {
19091920 this . waitForReplicatorTimeout = this . timeUntilRoleMaturity ; // does not makes sense to expect a replicator to mature faster than it is reachable
19101921 }
19111922
1923+ if ( this . waitForReplicatorRequestIntervalMs <= 0 ) {
1924+ throw new Error (
1925+ "waitForReplicatorRequestIntervalMs must be a positive number" ,
1926+ ) ;
1927+ }
1928+ if (
1929+ this . waitForReplicatorRequestMaxAttempts != null &&
1930+ this . waitForReplicatorRequestMaxAttempts <= 0
1931+ ) {
1932+ throw new Error (
1933+ "waitForReplicatorRequestMaxAttempts must be a positive number" ,
1934+ ) ;
1935+ }
1936+
19121937 this . _closeController = new AbortController ( ) ;
19131938 this . _isTrustedReplicator = options ?. canReplicate ;
19141939 this . keep = options ?. keep ;
@@ -3360,11 +3385,13 @@ export class SharedLog<
33603385 } , timeoutMs ) ;
33613386
33623387 let requestAttempts = 0 ;
3363- const requestIntervalMs = 1000 ;
3364- const maxRequestAttempts = Math . max (
3365- 3 ,
3366- Math . ceil ( timeoutMs / requestIntervalMs ) ,
3367- ) ;
3388+ const requestIntervalMs = this . waitForReplicatorRequestIntervalMs ;
3389+ const maxRequestAttempts =
3390+ this . waitForReplicatorRequestMaxAttempts ??
3391+ Math . max (
3392+ WAIT_FOR_REPLICATOR_REQUEST_MIN_ATTEMPTS ,
3393+ Math . ceil ( timeoutMs / requestIntervalMs ) ,
3394+ ) ;
33683395
33693396 const requestReplicationInfo = ( ) => {
33703397 if ( settled || this . closed ) {
0 commit comments