formatting

This commit is contained in:
2026-08-10 04:02:41 +00:00
parent 6f6bddf560
commit 04e61b7208
2 changed files with 8 additions and 9 deletions
+4 -3
View File
@@ -267,17 +267,18 @@ export class ExponentialBackoff {
// Wait for the delay or the abort signal
await new Promise((resolve, reject) => {
// Set a timeout to resolve the promise after the delay
// eslint-disable-next-line prefer-const
let timeout: ReturnType<typeof setTimeout>;
// Handle the abort signal
const abortHandler = () => {
const abortHandler = (): void => {
clearTimeout(timeout);
abortController.signal.removeEventListener('abort', abortHandler);
reject(new ExponentialBackoffStoppedRetriesError(abortController.signal.reason));
};
// Handle the timeout
const timeoutHandler = () => {
const timeoutHandler = (): void => {
abortController.signal.removeEventListener('abort', abortHandler);
resolve(undefined);
};
@@ -287,7 +288,7 @@ export class ExponentialBackoff {
// Add the abort handler to the abort signal
abortController.signal.addEventListener('abort', abortHandler);
})
});
attempt++;
}
+3 -5
View File
@@ -328,8 +328,7 @@ const testExponentialBackoffRunDelayAbortedWhenAbortSignal = async (): Promise<v
throw new Error('abort is not defined');
}
// Check that the rsult is still pending
expect(result).not.resolves;
// Check that the abort function is defined
expect(abort).toBeDefined();
// Abort the exponential backoff
@@ -337,11 +336,11 @@ const testExponentialBackoffRunDelayAbortedWhenAbortSignal = async (): Promise<v
// Expect the result to be rejected with an ExponentialBackoffStoppedRetriesError
await expect(result).rejects.toThrow(ExponentialBackoffStoppedRetriesError);
}
finally {
} finally {
vi.useRealTimers();
}
};
/**
* Tests the {@link ExponentialBackoff.from} factory and subsequent instance {@link ExponentialBackoff.run}
* as an alternative to the static helper.
@@ -629,7 +628,6 @@ const testExponentialBackoffValidateOptionsRejectsNaN = (): void => {
}
};
/** Tests that passing undefined into the constructor does not cause an error during spread */
const testExponentialBackoffConstructorDoesNotCauseErrorDuringSpread = async (): Promise<void> => {
const options = {