Skip to content

Commit

Permalink
Fix retry
Browse files Browse the repository at this point in the history
  • Loading branch information
johnwatson484 committed Mar 11, 2022
1 parent c7561c3 commit ab823b6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 2 additions & 3 deletions app/retry/index.js → app/retry.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
async function retry (fn, retriesLeft = 5, interval = 1000, exponential = false) {
try {
const val = await fn()
return val
return (await fn())
} catch (err) {
if (retriesLeft) {
if (retriesLeft > 0) {
await new Promise(resolve => setTimeout(resolve, interval))
return retry(fn, retriesLeft - 1, exponential ? interval * 2 : interval, exponential)
} else {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ffc-messaging",
"version": "2.4.0",
"version": "2.4.1",
"description": "Messaging npm module for FFC services",
"main": "index.js",
"repository": {
Expand Down

0 comments on commit ab823b6

Please sign in to comment.