From be46e0b5dd8d35493f4ea59f752ea2240a03ddcb Mon Sep 17 00:00:00 2001 From: Rithvik Nishad Date: Thu, 12 Dec 2024 02:53:30 +0000 Subject: [PATCH] Gracefully handle PR events for potentially deleted contributor (#557) --- scraper/src/github-scraper/parseEvents.ts | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/scraper/src/github-scraper/parseEvents.ts b/scraper/src/github-scraper/parseEvents.ts index f3a1650c..03edf57b 100644 --- a/scraper/src/github-scraper/parseEvents.ts +++ b/scraper/src/github-scraper/parseEvents.ts @@ -191,7 +191,16 @@ export const parseEvents = async (events: IGitHubEvent[]) => { event.payload.action === "closed" && event.payload.pull_request?.merged ) { - const turnaroundTime = await calculateTurnaroundTime(event); + let turnaroundTime: number | undefined = undefined; + try { + turnaroundTime = await calculateTurnaroundTime(event); + } catch (e) { + console.error( + `Error calculating turnaround time for event ${event.id}: ${e}`, + `Likely due to PR author ${event.payload.pull_request.user.login} being deleted`, + event, + ); + } appendEvent(event.payload.pull_request.user.login, { type: "pr_merged", title: `${event.repo.name}#${event.payload.pull_request.number}`, @@ -200,7 +209,14 @@ export const parseEvents = async (events: IGitHubEvent[]) => { text: event.payload.pull_request.title, turnaround_time: turnaroundTime, }); - await addCollaborations(event, eventTime); + try { + await addCollaborations(event, eventTime); + } catch (e) { + console.error( + `Error adding collaborations for event ${event.id}: ${e}`, + event, + ); + } } break; case "PullRequestReviewEvent":