Add abort signal to exponential backoff

This commit is contained in:
2026-07-18 13:18:01 +00:00
parent bce4c1552e
commit 873a075329
2 changed files with 75 additions and 12 deletions

View File

@@ -7,3 +7,16 @@ export class ExponentialBackoffMaxRetriesHitError extends Error {
this.name = 'ExponentialBackoffMaxRetriesHitError';
}
}
/**
* Error thrown when the exponential backoff retries are stopped
*/
export class ExponentialBackoffStoppedRetriesError extends Error {
constructor(reason: unknown) {
// Convert the reason to an error if it is not an error
const reasonError = reason instanceof Error ? reason : new Error(`${reason}`);
super(`Exponential backoff was aborted: "${reasonError.message}"`, { cause: reasonError });
this.name = 'ExponentialBackoffStoppedRetriesError';
}
}