Skip to content

Commit

Permalink
Gracefully handle PR events for potentially deleted contributor (#557)
Browse files Browse the repository at this point in the history
  • Loading branch information
rithviknishad authored Dec 12, 2024
1 parent 21a7beb commit be46e0b
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions scraper/src/github-scraper/parseEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`,
Expand All @@ -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":
Expand Down

0 comments on commit be46e0b

Please sign in to comment.