Skip to content

Commit 30c9f26

Browse files
authored
FFM-11852 Stop fallback Poller if stream resumes during a polling request (#131)
1 parent 1e4218b commit 30c9f26

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@harnessio/ff-javascript-client-sdk",
3-
"version": "1.27.0-rc.0",
3+
"version": "1.27.0",
44
"author": "Harness",
55
"license": "Apache-2.0",
66
"main": "dist/sdk.cjs.js",

src/poller.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,12 @@ export default class Poller {
3232
}
3333

3434
private poll(): void {
35+
if (!this.isRunning) return
3536
this.attemptFetch().finally(() => {
36-
this.timeoutId = setTimeout(() => this.poll(), this.configurations.pollingInterval)
37+
// Check if poller is still running before setting the next timeout
38+
if (this.isRunning) {
39+
this.timeoutId = setTimeout(() => this.poll(), this.configurations.pollingInterval)
40+
}
3741
})
3842
}
3943

@@ -70,9 +74,9 @@ export default class Poller {
7074

7175
public stop(): void {
7276
if (this.timeoutId) {
77+
this.isRunning = false
7378
clearTimeout(this.timeoutId)
7479
this.timeoutId = undefined
75-
this.isRunning = false
7680
this.eventBus.emit(Event.POLLING_STOPPED)
7781
this.logDebugMessage('Polling stopped')
7882
}

0 commit comments

Comments
 (0)