Skip to content

Commit

Permalink
fix: delay to throw and retry on tiny events ended with 503 (rate limit)
Browse files Browse the repository at this point in the history
  • Loading branch information
leomp12 committed Sep 12, 2024
1 parent 99582f1 commit 70c5b95
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions functions/lib/pubsub/webhook-tiny.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,20 @@ module.exports = async (
if (!err && isDone) {
return resolve(true)
}
if (err?.config?.url) {
const { method, url } = err.config
logger.warn(`${method} ${url} failed`, {
data: err.config.data,
response: err.response?.data,
status: err.response?.status
})
if (err.response?.status === 503) {
setTimeout(() => {
throw err
}, 1000)
return
}
}
throw err
}
}
Expand Down Expand Up @@ -99,6 +113,12 @@ module.exports = async (
response: err.response?.data,
status: err.response?.status
})
if (err.response?.status === 503) {
setTimeout(() => {
throw err
}, 1000)
return
}
}
throw err
}
Expand Down

0 comments on commit 70c5b95

Please sign in to comment.