Skip to content

Commit 73a300c

Browse files
remove abort tests
1 parent 162f5b9 commit 73a300c

File tree

2 files changed

+8
-49
lines changed

2 files changed

+8
-49
lines changed

src/integrationTests/basic.test.ts

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -910,51 +910,6 @@ testCookieAndLocalStorage(() => {
910910
});
911911
});
912912

913-
describe('abort()', () => {
914-
test('should not clear cookie', () => {
915-
const identity = makeIdentityV2();
916-
setUid2(identity, useCookie);
917-
uid2.abort();
918-
expect(getUid2(useCookie).advertising_token).toBe(identity.advertising_token);
919-
});
920-
test('should abort refresh timer', () => {
921-
uid2.init({
922-
callback: callback,
923-
identity: makeIdentityV2(),
924-
useCookie: useCookie,
925-
});
926-
expect(setTimeout).toHaveBeenCalledTimes(1);
927-
expect(clearTimeout).not.toHaveBeenCalled();
928-
uid2.abort();
929-
expect(setTimeout).toHaveBeenCalledTimes(1);
930-
expect(clearTimeout).toHaveBeenCalledTimes(1);
931-
});
932-
test('should not abort refresh timer if not timer is set', () => {
933-
uid2.init({
934-
callback: callback,
935-
identity: makeIdentityV2({ refresh_from: Date.now() - 100000 }),
936-
useCookie: useCookie,
937-
});
938-
expect(setTimeout).not.toHaveBeenCalled();
939-
expect(clearTimeout).not.toHaveBeenCalled();
940-
uid2.abort();
941-
expect(setTimeout).not.toHaveBeenCalled();
942-
expect(clearTimeout).not.toHaveBeenCalled();
943-
});
944-
test('should abort refresh token request', () => {
945-
uid2.init({
946-
callback: callback,
947-
identity: makeIdentityV2({ refresh_from: Date.now() - 100000 }),
948-
useCookie: useCookie,
949-
});
950-
expect(xhrMock.send).toHaveBeenCalledTimes(1);
951-
expect(xhrMock.abort).not.toHaveBeenCalled();
952-
uid2.abort();
953-
expect(xhrMock.send).toHaveBeenCalledTimes(1);
954-
expect(xhrMock.abort).toHaveBeenCalledTimes(1);
955-
});
956-
});
957-
958913
describe('disconnect()', () => {
959914
test('should clear cookie', () => {
960915
setUid2(makeIdentityV2(), useCookie);

src/sdkBase.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,12 @@ export abstract class SdkBase {
199199
}
200200

201201
public disconnect() {
202-
this.abort(`${this._product.name} SDK disconnected.`);
202+
this._tokenPromiseHandler.rejectAllPromises(new Error(`${this._product.name} SDK aborted.`));
203+
if (this._refreshTimerId) {
204+
clearTimeout(this._refreshTimerId);
205+
this._refreshTimerId = null;
206+
}
207+
if (this._apiClient) this._apiClient.abortActiveRequests();
203208
// Note: This silently fails to clear the cookie if init hasn't been called and a cookieDomain is used!
204209
if (this._storageManager) this._storageManager.removeValues();
205210
else
@@ -216,7 +221,7 @@ export abstract class SdkBase {
216221

217222
// Note: This doesn't invoke callbacks. It's a hard, silent reset.
218223
/**
219-
* @deprecated abort() should no longer be used for anything
224+
* @deprecated abort() is deprecated in version 3.10.0. Will be removed in June 2025. Use disconnect() instead
220225
*/
221226
public abort(reason?: string) {
222227
this._tokenPromiseHandler.rejectAllPromises(
@@ -406,8 +411,7 @@ export abstract class SdkBase {
406411
} else if (validity.status === IdentityStatus.OPTOUT || status === IdentityStatus.OPTOUT) {
407412
this._storageManager.setOptout();
408413
} else {
409-
this.abort();
410-
this._storageManager.removeValues();
414+
this.disconnect();
411415
}
412416

413417
this._identity = this._storageManager.loadIdentity();

0 commit comments

Comments
 (0)