From 2b8009d8405f168d586aac51286b42f854ce7158 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Tue, 23 Jul 2024 23:06:00 -0500 Subject: [PATCH] trends: catch initial queries --- src/controllers/api/trends.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/controllers/api/trends.ts b/src/controllers/api/trends.ts index d581ddc8..181d8dc9 100644 --- a/src/controllers/api/trends.ts +++ b/src/controllers/api/trends.ts @@ -9,7 +9,10 @@ import { generateDateRange, Time } from '@/utils/time.ts'; import { unfurlCardCached } from '@/utils/unfurl.ts'; import { renderStatus } from '@/views/mastodon/statuses.ts'; -let trendingHashtagsCache = getTrendingHashtags(); +let trendingHashtagsCache = getTrendingHashtags().catch((e) => { + console.error(`Failed to get trending hashtags: ${e}`); + return Promise.resolve([]); +}); Deno.cron('update trending hashtags cache', '35 * * * *', async () => { try { @@ -52,7 +55,10 @@ async function getTrendingHashtags() { }); } -let trendingLinksCache = getTrendingLinks(); +let trendingLinksCache = getTrendingLinks().catch((e) => { + console.error(`Failed to get trending links: ${e}`); + return Promise.resolve([]); +}); Deno.cron('update trending links cache', '50 * * * *', async () => { try {