Skip to content

Commit be7faa3

Browse files
committed
fix invalid date crash
1 parent ed012e0 commit be7faa3

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

app/src/lib/format-relative.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ const getRelativeFormatter = mem(
1515
)
1616

1717
export function formatRelative(ms: number) {
18+
if (!Number.isFinite(ms)) {
19+
return 'Invalid date'
20+
}
21+
1822
const formatter = getRelativeFormatter('en-US', { numeric: 'auto' })
1923

2024
const sign = ms < 0 ? -1 : 1

app/src/ui/branches/branch-renderer.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ export function getDefaultAriaLabelForBranch(item: IBranchListItem): string {
4646
return branch.name
4747
}
4848

49+
if (Number.isNaN(authorDate.getTime())) {
50+
return branch.name
51+
}
52+
4953
const { relativeText } = getRelativeTimeInfoFromDate(authorDate, true)
5054
return `${item.branch.name} ${relativeText}`
5155
}

0 commit comments

Comments
 (0)