File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed
Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -97,13 +97,18 @@ export default function initPoller(
9797 stopped = true ;
9898 if ( nextTimer ) {
9999 clearTimeout ( nextTimer ) ;
100+ nextTimer = undefined ;
100101 }
101102 logger . info ( 'Eppo SDK polling stopped' ) ;
102103 }
103104 } ;
104105
105106 async function poll ( ) {
106107 if ( stopped ) {
108+ if ( nextTimer ) {
109+ clearTimeout ( nextTimer ) ;
110+ nextTimer = undefined ;
111+ }
107112 return ;
108113 }
109114
@@ -134,10 +139,14 @@ export default function initPoller(
134139 `Eppo SDK reached maximum of ${ failedAttempts } failed polling attempts. Stopping polling` ,
135140 ) ;
136141 stop ( ) ;
142+ return ;
137143 }
138144 }
139145
140- setTimeout ( poll , nextPollMs ) ;
146+ // Check stopped state again before setting up next timer to handle race condition
147+ if ( ! stopped ) {
148+ nextTimer = setTimeout ( poll , nextPollMs ) ;
149+ }
141150 }
142151
143152 return {
You can’t perform that action at this time.
0 commit comments