diff --git a/packages/core/src/errors.ts b/packages/core/src/errors.ts index c24f465f38..6b02be04c2 100644 --- a/packages/core/src/errors.ts +++ b/packages/core/src/errors.ts @@ -201,9 +201,11 @@ export enum CustomErrorCodes { OAUTH_REFRESH_FAILED = 'OAUTH_REFRESH_FAILED', // Destination has spent more than the alloted time and needs to self-terminate SELF_TIMEOUT = 'SELF_TIMEOUT', - // Fallback error code if no other error code matches - UNKNOWN_ERROR = 'UNKNOWN_ERROR' + UNKNOWN_ERROR = 'UNKNOWN_ERROR', + // Destination not ready to process requests. Can be used in scenarios where we want to retry because destination is still processing some events due to race condition. + // Example: In Adobe Target, if profile creation is in progress, any updateProfile calls will fail. In such cases, we can use this error code to indicate that destination is not ready yet. + DESTINATION_NOT_READY = 'DESTINATION_NOT_READY' } const HTTP_ERROR_CODE_MAP: Record = { diff --git a/packages/destination-actions/src/destinations/adobe-target/adobeTarget_operations.ts b/packages/destination-actions/src/destinations/adobe-target/adobeTarget_operations.ts index e356a6658b..3e546246f6 100644 --- a/packages/destination-actions/src/destinations/adobe-target/adobeTarget_operations.ts +++ b/packages/destination-actions/src/destinations/adobe-target/adobeTarget_operations.ts @@ -1,4 +1,4 @@ -import { RequestClient, IntegrationError, APIError } from '@segment/actions-core' +import { RequestClient, IntegrationError, ErrorCodes } from '@segment/actions-core' import { StatsContext } from '@segment/actions-core/destination-kit' function getNestedObjects(obj: { [x: string]: any }, objectPath = '', attributes: { [x: string]: string } = {}) { @@ -76,7 +76,9 @@ export default class AdobeTarget { statsContext?.statsClient.incr('actions-adobe-target.profile-not-found', 1, statsContext.tags) } - throw new APIError(error.message, errorCode) + // TOO_EARLY error type indicates that this error is retryable error type but server is not ready yet to process the request. + // Centrifuge dosn't retry 425 so we keep the error code as 500. + throw new IntegrationError(error.message, ErrorCodes.DESTINATION_NOT_READY, errorCode) } }