@@ -22,7 +22,7 @@ export interface IConnectTweetStreamParams {
22
22
}
23
23
24
24
/** Returns a number of milliseconds to wait for {tryOccurence} (starting from 1) */
25
- export type TStreamConnectRetryFn = ( tryOccurence : number ) => number ;
25
+ export type TStreamConnectRetryFn = ( tryOccurence : number , error ?: any ) => number ;
26
26
27
27
// In seconds
28
28
const basicRetriesAttempt = [ 5 , 15 , 30 , 60 , 90 , 120 , 180 , 300 , 600 , 900 ] ;
@@ -261,7 +261,7 @@ export class TweetStream<T = any> extends EventEmitter {
261
261
// Only make a reconnection attempt if autoReconnect is true!
262
262
// Otherwise, let error be propagated
263
263
if ( this . autoReconnect ) {
264
- this . makeAutoReconnectRetry ( 0 ) ;
264
+ this . makeAutoReconnectRetry ( 0 , e ) ;
265
265
} else {
266
266
throw e ;
267
267
}
@@ -327,12 +327,12 @@ export class TweetStream<T = any> extends EventEmitter {
327
327
message : `Reconnect error - ${ retryOccurence + 1 } attempts made yet.` ,
328
328
} ) ;
329
329
330
- this . makeAutoReconnectRetry ( retryOccurence ) ;
330
+ this . makeAutoReconnectRetry ( retryOccurence , e ) ;
331
331
}
332
332
}
333
333
334
- protected makeAutoReconnectRetry ( retryOccurence : number ) {
335
- const nextRetry = this . nextRetryTimeout ( retryOccurence + 1 ) ;
334
+ protected makeAutoReconnectRetry ( retryOccurence : number , error : any ) {
335
+ const nextRetry = this . nextRetryTimeout ( retryOccurence + 1 , error ) ;
336
336
337
337
this . retryTimeout = setTimeout ( ( ) => {
338
338
this . onConnectionError ( retryOccurence + 1 ) ;
0 commit comments