Skip to content

Commit 7770052

Browse files
Adebesin-Cellclaude
andcommitted
fix: add fetch timeouts and boost download number prominence
- Add 2.5s timeout to npm API requests to prevent OG image render stalls - Increase download numbers to text-3xl font-bold white for better visual prominence on the compare OG card Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 9fcab62 commit 7770052

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

app/components/OgImage/Compare.vue

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,24 @@ interface PkgStats {
3838
3939
const stats = ref<PkgStats[]>([])
4040
41+
const FETCH_TIMEOUT_MS = 2500
42+
4143
try {
4244
const results = await Promise.all(
4345
displayPackages.value.map(async (name, index) => {
4446
const encoded = encodePackageName(name)
4547
const [dlData, pkgData] = await Promise.all([
4648
$fetch<{ downloads: number }>(
4749
`https://api.npmjs.org/downloads/point/last-week/${encoded}`,
50+
{ timeout: FETCH_TIMEOUT_MS },
51+
).catch(() => null),
52+
$fetch<{ 'dist-tags'?: { latest?: string } }>(
53+
`https://registry.npmjs.org/${encoded}`,
54+
{
55+
timeout: FETCH_TIMEOUT_MS,
56+
headers: { Accept: 'application/vnd.npm.install-v1+json' },
57+
},
4858
).catch(() => null),
49-
$fetch<{ 'dist-tags'?: { latest?: string } }>(`https://registry.npmjs.org/${encoded}`, {
50-
headers: { Accept: 'application/vnd.npm.install-v1+json' },
51-
}).catch(() => null),
5259
])
5360
return {
5461
name,
@@ -141,7 +148,7 @@ function barPct(downloads: number): string {
141148
<span class="text-2xl font-semibold tracking-tight" :style="{ color: pkg.color }">
142149
{{ pkg.name }}
143150
</span>
144-
<span class="text-2xl font-medium text-[#d4d4d4]">
151+
<span class="text-3xl font-bold text-[#fafafa]">
145152
{{ formatDownloads(pkg.downloads) }}/wk
146153
</span>
147154
<span

0 commit comments

Comments
 (0)