diff --git a/src/backport.ts b/src/backport.ts index 0ab986f..df53439 100644 --- a/src/backport.ts +++ b/src/backport.ts @@ -142,8 +142,8 @@ export const backport = (task: Task) => new Promise((resolve, reject) => { addReaction(octokit, task, Reaction.HOORAY) } catch (e) { // Add a thumbs down reaction to the comment to indicate that we failed - addReaction(octokit, task, Reaction.THUMBS_DOWN) try { + addReaction(octokit, task, Reaction.THUMBS_DOWN) const failureComment = getFailureCommentBody(task, backportBranch, e?.message) await commentOnPR(octokit, task, failureComment) } catch (e) { diff --git a/src/index.ts b/src/index.ts index 9c0b773..02dcb05 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,6 +1,6 @@ import { createNodeMiddleware } from '@octokit/webhooks' import { createServer } from 'http' -import { info, error } from 'node:console' +import { info, error, warn } from 'node:console' import { Octokit } from '@octokit/rest' import { addToQueue } from './queue' @@ -167,7 +167,12 @@ app.webhooks.on(['issue_comment.created'], async ({ payload }) => { const isMerged = typeof payload.issue?.pull_request?.merged_at === 'string' if (isClosed && !isMerged) { - addReaction(authOctokit, { owner, repo, commentId } as Task, Reaction.THUMBS_DOWN) + try { + addReaction(authOctokit, { owner, repo, commentId } as Task, Reaction.THUMBS_DOWN) + } catch (e) { + // Safely ignore + warn(`Failed to add reaction to comment: ${e.message}`) + } error(`Ignoring comment on closed but unmerged PR ${htmlUrl}`) return } @@ -251,7 +256,12 @@ app.webhooks.on(['issue_comment.created'], async ({ payload }) => { } catch (e) { // This should really not happen, but if it does, we want to know about it if (e instanceof Error) { - addReaction(authOctokit, { owner, repo, commentId } as Task, Reaction.THUMBS_DOWN) + try { + addReaction(authOctokit, { owner, repo, commentId } as Task, Reaction.THUMBS_DOWN) + } catch (e) { + // Safely ignore + warn(`Failed to add reaction to comment: ${e.message}`) + } error(`Failed to handle backport request: ${e.message}`) return }