@@ -42,7 +42,6 @@ const DEFAULT_MAX_RETRY_ATTEMPTS = 10;
4242const DEFAULT_SWEEP_IN_BUF_INTERVAL_MS = 5 * 1000 ;
4343const DEFAULT_SWEEP_REPAIR_INTERVAL_MS = 10 * 1000 ; // 10 seconds
4444const DEFAULT_PROCESS_TASK_MIN_ELAPSE_MS = 1000 ;
45- const DEFAULT_SDSR_FALLBACK_TIMEOUT_MS = 120 * 1000 ; // 2 minutes
4645
4746const IRRECOVERABLE_SENDING_ERRORS : LightPushError [ ] = [
4847 LightPushError . ENCODE_FAILED ,
@@ -118,22 +117,14 @@ export type ReliableChannelOptions = MessageChannelOptions & {
118117
119118 /**
120119 * Strategy for retrieving missing messages.
121- * - 'both': Use SDS-R peer repair and Store queries (default)
120+ * - 'both': Use SDS-R peer repair and Store queries in parallel (default)
122121 * - 'sds-r-only': Only use SDS-R peer repair
123122 * - 'store-only': Only use Store queries (legacy behavior)
124123 * - 'none': No automatic retrieval
125124 *
126125 * @default 'both'
127126 */
128127 retrievalStrategy ?: "both" | "sds-r-only" | "store-only" | "none" ;
129-
130- /**
131- * How long to wait for SDS-R repair before falling back to Store.
132- * Only applies when retrievalStrategy is 'both'.
133- *
134- * @default 120,000 (2 minutes - matches SDS-R T_max)
135- */
136- sdsrFallbackTimeoutMs ?: number ;
137128} ;
138129
139130/**
@@ -179,11 +170,6 @@ export class ReliableChannel<
179170 | "sds-r-only"
180171 | "store-only"
181172 | "none" ;
182- private readonly sdsrFallbackTimeoutMs : number ;
183- private readonly missingMessageTimeouts : Map <
184- string ,
185- ReturnType < typeof setTimeout >
186- > ;
187173 private _started : boolean ;
188174
189175 private constructor (
@@ -249,9 +235,6 @@ export class ReliableChannel<
249235 options ?. processTaskMinElapseMs ?? DEFAULT_PROCESS_TASK_MIN_ELAPSE_MS ;
250236
251237 this . retrievalStrategy = options ?. retrievalStrategy ?? "both" ;
252- this . sdsrFallbackTimeoutMs =
253- options ?. sdsrFallbackTimeoutMs ?? DEFAULT_SDSR_FALLBACK_TIMEOUT_MS ;
254- this . missingMessageTimeouts = new Map ( ) ;
255238
256239 // Only enable Store retrieval based on strategy
257240 if ( this . _retrieve && this . shouldUseStore ( ) ) {
@@ -458,13 +441,7 @@ export class ReliableChannel<
458441 // missing messages or the status of previous outgoing messages
459442 this . messageChannel . pushIncomingMessage ( sdsMessage , retrievalHint ) ;
460443
461- // Cancel Store fallback timeout if message was retrieved
462- const timeout = this . missingMessageTimeouts . get ( sdsMessage . messageId ) ;
463- if ( timeout ) {
464- clearTimeout ( timeout ) ;
465- this . missingMessageTimeouts . delete ( sdsMessage . messageId ) ;
466- }
467-
444+ // Remove from Store retriever if message was retrieved
468445 this . missingMessageRetriever ?. removeMissingMessage ( sdsMessage . messageId ) ;
469446
470447 if ( sdsMessage . content && sdsMessage . content . length > 0 ) {
@@ -544,7 +521,6 @@ export class ReliableChannel<
544521 this . stopSync ( ) ;
545522 this . stopSweepIncomingBufferLoop ( ) ;
546523 this . stopRepairSweepLoop ( ) ;
547- this . clearMissingMessageTimeouts ( ) ;
548524 this . missingMessageRetriever ?. stop ( ) ;
549525 this . queryOnConnect ?. stop ( ) ;
550526 // TODO unsubscribe
@@ -587,13 +563,6 @@ export class ReliableChannel<
587563 if ( this . sweepRepairInterval ) clearInterval ( this . sweepRepairInterval ) ;
588564 }
589565
590- private clearMissingMessageTimeouts ( ) : void {
591- for ( const timeout of this . missingMessageTimeouts . values ( ) ) {
592- clearTimeout ( timeout ) ;
593- }
594- this . missingMessageTimeouts . clear ( ) ;
595- }
596-
597566 private shouldUseStore ( ) : boolean {
598567 return (
599568 this . retrievalStrategy === "both" ||
@@ -773,35 +742,28 @@ export class ReliableChannel<
773742 MessageChannelEvent . InMessageMissing ,
774743 ( event ) => {
775744 for ( const { messageId, retrievalHint } of event . detail ) {
776- // Coordinated retrieval strategy
745+ // Parallel retrieval strategy
777746 if ( this . retrievalStrategy === "both" ) {
778- // SDS-R will attempt first, schedule Store fallback
779- // Note: missingMessageRetriever only exists if Store protocol is available
747+ // Both SDS-R and Store work in parallel
748+ // SDS-R automatically handles repair via RepairManager
749+ // Store retrieval starts immediately
780750 if ( retrievalHint && this . missingMessageRetriever ) {
781- const timeout = setTimeout ( ( ) => {
782- // Still missing after SDS-R timeout, try Store
783- log . info (
784- `Message ${ messageId } not retrieved via SDS-R, falling back to Store`
785- ) ;
786- this . missingMessageRetriever ?. addMissingMessage (
787- messageId ,
788- retrievalHint
789- ) ;
790- this . missingMessageTimeouts . delete ( messageId ) ;
791- } , this . sdsrFallbackTimeoutMs ) ;
792-
793- this . missingMessageTimeouts . set ( messageId , timeout ) ;
751+ this . missingMessageRetriever . addMissingMessage (
752+ messageId ,
753+ retrievalHint
754+ ) ;
794755 }
795756 } else if ( this . retrievalStrategy === "store-only" ) {
796- // Immediate Store retrieval
757+ // Immediate Store retrieval only
797758 if ( retrievalHint && this . missingMessageRetriever ) {
798759 this . missingMessageRetriever . addMissingMessage (
799760 messageId ,
800761 retrievalHint
801762 ) ;
802763 }
803764 }
804- // For 'sds-r-only' and 'none', SDS-R handles it or nothing happens
765+ // For 'sds-r-only', only SDS-R repair manager operates
766+ // For 'none', nothing happens
805767 }
806768 }
807769 ) ;
0 commit comments