@@ -34,8 +34,8 @@ export function resolveOptions(userOptions?: Partial<CircuitStartOptions>): Circ
34
34
}
35
35
36
36
export interface ReconnectionOptions {
37
- maxRetries : number ;
38
- retryIntervalMilliseconds : number ;
37
+ maxRetries ? : number ;
38
+ retryIntervalMilliseconds : number | ( ( previousAttempts : number , maxRetries ?: number ) => number | undefined | null ) ;
39
39
dialogId : string ;
40
40
}
41
41
@@ -49,15 +49,34 @@ export interface ReconnectionHandler {
49
49
onConnectionUp ( ) : void ;
50
50
}
51
51
52
+ function computeDefaultRetryInterval ( previousAttempts : number , maxRetries ?: number ) : number | null {
53
+ if ( maxRetries && previousAttempts >= maxRetries ) {
54
+ return null ;
55
+ }
56
+
57
+ if ( previousAttempts < 10 ) {
58
+ // Retry as quickly as possible for the first 10 tries
59
+ return 0 ;
60
+ }
61
+
62
+ if ( previousAttempts < 20 ) {
63
+ // Retry every 5 seconds for the next 10 tries
64
+ return 5000 ;
65
+ }
66
+
67
+ // Then retry every 30 seconds indefinitely
68
+ return 30000 ;
69
+ }
70
+
52
71
const defaultOptions : CircuitStartOptions = {
53
72
// eslint-disable-next-line @typescript-eslint/no-empty-function
54
73
configureSignalR : ( _ ) => { } ,
55
74
logLevel : LogLevel . Warning ,
56
75
initializers : undefined ! ,
57
76
circuitHandlers : [ ] ,
58
77
reconnectionOptions : {
59
- maxRetries : 8 ,
60
- retryIntervalMilliseconds : 20000 ,
78
+ maxRetries : 30 ,
79
+ retryIntervalMilliseconds : computeDefaultRetryInterval ,
61
80
dialogId : 'components-reconnect-modal' ,
62
81
} ,
63
82
} ;
0 commit comments