Document await in exponential backoff run function
This commit is contained in:
@@ -90,6 +90,8 @@ export class ExponentialBackoff {
|
|||||||
|
|
||||||
while (attempt < this.options.maxAttempts || unlimitedAttempts) {
|
while (attempt < this.options.maxAttempts || unlimitedAttempts) {
|
||||||
try {
|
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();
|
return await taskFn();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// Store the error in case we fail every attempt
|
// Store the error in case we fail every attempt
|
||||||
|
|||||||
Reference in New Issue
Block a user