Skip to content

Commit

Permalink
Merge pull request #169 from Financial-Times/CPP-702-nori-prs-bugfix
Browse files Browse the repository at this point in the history
CPP-702 Change from pending to done to avoid hanging process
  • Loading branch information
serena97 authored Dec 13, 2021
2 parents 70ebd06 + bca8527 commit 7b9f805
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/commands/prs.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ exports.handler = async ({ templates: { title, body } }, state) => {
await new Promise(r => setTimeout(r, PR_CREATION_TIMEOUT_MS))
}
}
getOctokit.clearPendingMessages()
}

exports.undo = async (_, state) => {
Expand Down
16 changes: 15 additions & 1 deletion src/lib/octokit.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,23 @@ const RETRY_LIMIT = 5

let client

const labels = new Set()

const clearPendingMessages = (status = 'done') => {
labels.forEach(label => {
logger.log(label, { status: status })
})
labels.clear()
}

const retryWrapper = (retryAfter, options, message) => {
if (options.request.retryCount === RETRY_LIMIT) {
clearPendingMessages('fail')
return
}
logger.log(`${message}, retrying after ${retryAfter}s`, {
const label = `${message}-${options.request.retryCount}`
labels.add(label)
logger.log(label, {
status: 'pending',
message: `${message}, retrying after ${retryAfter}s`,
})
Expand All @@ -39,3 +51,5 @@ module.exports = token => {

return client
}

module.exports.clearPendingMessages = clearPendingMessages

0 comments on commit 7b9f805

Please sign in to comment.