diff --git a/source/exponential-backoff.ts b/source/exponential-backoff.ts index ce16f00..b19bdeb 100644 --- a/source/exponential-backoff.ts +++ b/source/exponential-backoff.ts @@ -90,6 +90,8 @@ export class ExponentialBackoff { while (attempt < this.options.maxAttempts || unlimitedAttempts) { try { + // Await the promise before returning so its execution context remains in the try-catch + // If we didn't await, this `run` function would successfully return and any errors would not be caught here. return await taskFn(); } catch (error) { // Store the error in case we fail every attempt