@@ -50,6 +50,7 @@ export class OrderedStrategy {
50
50
private polling : boolean ;
51
51
private toPoll : Heap < { chain : RelationChain ; expected : string [ ] } > ;
52
52
private pollInterval ?: number ;
53
+ private pollingIsScheduled : boolean ;
53
54
54
55
private cancled = false ;
55
56
@@ -70,6 +71,7 @@ export class OrderedStrategy {
70
71
this . notifier = notifier ;
71
72
this . polling = polling ;
72
73
this . pollInterval = pollInterval ;
74
+ this . pollingIsScheduled = false ;
73
75
74
76
this . toPoll = new Heap ( ( a , b ) => a . chain . ordering ( b . chain ) ) ;
75
77
this . launchedRelations = new Heap ( ( a , b ) => a . ordering ( b ) ) ;
@@ -86,6 +88,7 @@ export class OrderedStrategy {
86
88
this . notifier . error ( error , { } ) ;
87
89
} ,
88
90
scheduleFetch : ( { target, expected } , { chain } ) => {
91
+ this . logger . debug ( `Scheduling fetch for mutable page: ${ target } ` ) ;
89
92
chain . target = target ;
90
93
this . toPoll . push ( { chain, expected } ) ;
91
94
this . notifier . mutable ( { } , { } ) ;
@@ -257,11 +260,13 @@ export class OrderedStrategy {
257
260
member = this . members . pop ( ) ;
258
261
}
259
262
260
- if ( this . polling ) {
261
- this . logger . debug ( "Polling is enabled, settings timeout" ) ;
263
+ // Make sure polling task is only scheduled once
264
+ if ( this . polling && ! this . pollingIsScheduled ) {
265
+ this . logger . debug ( `Polling is enabled, setting timeout of ${ this . pollInterval || 1000 } ms to poll` ) ;
262
266
setTimeout ( ( ) => {
263
267
if ( this . cancled ) return ;
264
268
269
+ this . pollingIsScheduled = false ;
265
270
this . notifier . pollCycle ( { } , { } ) ;
266
271
const toPollArray = this . toPoll . toArray ( ) ;
267
272
this . logger . debug (
@@ -278,6 +283,7 @@ export class OrderedStrategy {
278
283
this . modulator . push ( rel ) ;
279
284
}
280
285
} , this . pollInterval || 1000 ) ;
286
+ this . pollingIsScheduled = true ;
281
287
} else {
282
288
this . logger . debug ( "Closing the notifier, polling is not set" ) ;
283
289
this . cancled = true ;
0 commit comments