From e726d1c25aea1bad2cbdf4bbec01aeaecbfd39f5 Mon Sep 17 00:00:00 2001 From: Harvmaster Date: Sat, 11 Jul 2026 12:54:42 +0000 Subject: [PATCH] Document await in exponential backoff run function --- source/exponential-backoff.ts | 2 ++ 1 file changed, 2 insertions(+) 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