@@ -98,6 +98,7 @@ type TimeoutInfo = {
9898 startTime : number ;
9999 timeout : number ;
100100 maxTotalTimeout ?: number ;
101+ resetTimeoutOnProgress : boolean ;
101102 onTimeout : ( ) => void ;
102103} ;
103104
@@ -179,13 +180,15 @@ export abstract class Protocol<
179180 messageId : number ,
180181 timeout : number ,
181182 maxTotalTimeout : number | undefined ,
182- onTimeout : ( ) => void
183+ onTimeout : ( ) => void ,
184+ resetTimeoutOnProgress : boolean = false
183185 ) {
184186 this . _timeoutInfo . set ( messageId , {
185187 timeoutId : setTimeout ( onTimeout , timeout ) ,
186188 startTime : Date . now ( ) ,
187189 timeout,
188190 maxTotalTimeout,
191+ resetTimeoutOnProgress,
189192 onTimeout
190193 } ) ;
191194 }
@@ -358,7 +361,9 @@ export abstract class Protocol<
358361 }
359362
360363 const responseHandler = this . _responseHandlers . get ( messageId ) ;
361- if ( this . _timeoutInfo . has ( messageId ) && responseHandler ) {
364+ const timeoutInfo = this . _timeoutInfo . get ( messageId ) ;
365+
366+ if ( timeoutInfo && responseHandler && timeoutInfo . resetTimeoutOnProgress ) {
362367 try {
363368 this . _resetTimeout ( messageId ) ;
364369 } catch ( error ) {
@@ -520,7 +525,7 @@ export abstract class Protocol<
520525 { timeout }
521526 ) ) ;
522527
523- this . _setupTimeout ( messageId , timeout , options ?. maxTotalTimeout , timeoutHandler ) ;
528+ this . _setupTimeout ( messageId , timeout , options ?. maxTotalTimeout , timeoutHandler , options ?. resetTimeoutOnProgress ?? false ) ;
524529
525530 this . _transport . send ( jsonrpcRequest ) . catch ( ( error ) => {
526531 this . _cleanupTimeout ( messageId ) ;
0 commit comments