diff --git a/packages/shared/src/utils/callWithRetry.ts b/packages/shared/src/utils/callWithRetry.ts index 4f9ccfd2f7c..84050f56591 100644 --- a/packages/shared/src/utils/callWithRetry.ts +++ b/packages/shared/src/utils/callWithRetry.ts @@ -4,6 +4,12 @@ function wait(ms: number) { const MAX_NUMBER_OF_RETRIES = 5; +/** + * Retry callback function every few hundred ms (with an exponential backoff + * based on the current attempt) until the maximum attempts has reached or + * the callback is executed successfully. The default number of maximum + * attempts is 5 and retries are triggered when callback throws an error. + */ export async function callWithRetry( fn: (...args: unknown[]) => Promise, attempt = 1, diff --git a/packages/shared/src/utils/url.ts b/packages/shared/src/utils/url.ts index 890e1ca422f..c9668586d08 100644 --- a/packages/shared/src/utils/url.ts +++ b/packages/shared/src/utils/url.ts @@ -28,6 +28,13 @@ export function addClerkPrefix(str: string | undefined) { return `clerk.${stripped}`; } +/** + * + * Retrieve the clerk-js major tag using the major version from the pkgVersion + * param or use the frontendApi to determine if the staging tag should be used. + * The default tag is `latest` and a `next` pkgVersion also exists to retrieve + * the next canary release. + */ export const getClerkJsMajorVersionOrTag = (frontendApi: string, pkgVersion?: string) => { if (!pkgVersion && isStaging(frontendApi)) { return 'staging'; @@ -44,6 +51,11 @@ export const getClerkJsMajorVersionOrTag = (frontendApi: string, pkgVersion?: st return pkgVersion.split('.')[0] || 'latest'; }; +/** + * + * Retrieve the clerk-js script url from the frontendApi and the major tag + * using the {@link getClerkJsMajorVersionOrTag} or a provided clerkJSVersion tag. + */ export const getScriptUrl = ( frontendApi: string, { pkgVersion, clerkJSVersion }: { pkgVersion?: string; clerkJSVersion?: string },