diff --git a/src/identityApiClient.ts b/src/identityApiClient.ts index 7d6f3d0f1..5af3cc4a1 100644 --- a/src/identityApiClient.ts +++ b/src/identityApiClient.ts @@ -173,7 +173,7 @@ export default function IdentityAPIClient( if (mpInstance._Store.identityCallInFlight) { invokeCallback( - callback as Callback, + callback, HTTPCodes.activeIdentityRequest, 'There is currently an Identity request processing. Please wait for this to return before requesting again' ); @@ -234,11 +234,13 @@ export default function IdentityAPIClient( false ); } catch (err) { + const errorMessage = (err as Error).message || 'Unknown Error'; + mpInstance._Store.identityCallInFlight = false; invokeCallback( - callback as Callback, + callback, HTTPCodes.noHttpCoverage, - err.toString() + errorMessage, ); error('Error sending identity request to servers' + ' - ' + err); } diff --git a/src/sdkRuntimeModels.ts b/src/sdkRuntimeModels.ts index 8a75191dc..cb94f7d56 100644 --- a/src/sdkRuntimeModels.ts +++ b/src/sdkRuntimeModels.ts @@ -3,7 +3,6 @@ import { DataPlanVersion } from '@mparticle/data-planning-models'; import { MPConfiguration, MPID, - Callback, IdentityApiData, } from '@mparticle/web-sdk'; import { IStore } from './store'; @@ -287,7 +286,7 @@ export interface SDKHelpersApi { ): boolean; isObject?(item: any); invokeCallback?( - callback: Callback, + callback: IdentityCallback, code: number, body: string, mParticleUser?: IMParticleUser, diff --git a/test/src/tests-identityApiClient.ts b/test/src/tests-identityApiClient.ts index 568305fb4..4cc7d0608 100644 --- a/test/src/tests-identityApiClient.ts +++ b/test/src/tests-identityApiClient.ts @@ -181,7 +181,7 @@ describe('Identity Api Client', () => { it('should call invokeCallback with an error if the fetch fails', async () => { fetchMock.post(urls.identify, { status: 500, - throws: 'server error', + throws: { message: 'server error' }, }, { overwriteRoutes: true, });