Skip to content

Commit d11b0ef

Browse files
Update syncTask util to properly log the stop task message
1 parent 4a44ac4 commit d11b0ef

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

src/sdkClient/sdkClient.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,22 +56,18 @@ export function sdkClientFactory(params: ISdkFactoryContext, isSharedClient?: bo
5656
// Mark the SDK as destroyed immediately
5757
sdkReadinessManager.readinessManager.destroy();
5858

59-
// For main client, release the SDK Key and record stat before flushing data
59+
// For main client, cleanup the SDK Key, listeners and scheduled jobs, and record stat before flushing data
6060
if (!isSharedClient) {
6161
releaseApiKey(settings.core.authorizationKey);
6262
telemetryTracker.sessionLength();
63+
signalListener && signalListener.stop();
64+
uniqueKeysTracker && uniqueKeysTracker.stop();
6365
}
6466

6567
// Stop background jobs
6668
syncManager && syncManager.stop();
6769

6870
return __flush().then(() => {
69-
// For main client, cleanup event listeners and scheduled jobs
70-
if (!isSharedClient) {
71-
signalListener && signalListener.stop();
72-
uniqueKeysTracker && uniqueKeysTracker.stop();
73-
}
74-
7571
// Cleanup storage
7672
return storage.destroy();
7773
});

src/sync/syncTask.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ export function syncTaskFactory<Input extends any[], Output = any>(log: ILogger,
6868
},
6969

7070
stop() {
71-
running = false;
72-
if (timeoutID) {
71+
if (running) {
72+
running = false;
7373
log.debug(SYNC_TASK_STOP, [taskName]);
7474
clearTimeout(timeoutID);
7575
timeoutID = undefined;

0 commit comments

Comments
 (0)