From 5ebde99320d6c330e42364e7372dd8e0faf50589 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Tue, 23 Jul 2024 22:19:10 -0500 Subject: [PATCH] trends: Deno.cron try/catch --- deno.lock | 2 ++ src/controllers/api/trends.ts | 16 ++++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/deno.lock b/deno.lock index f94857fe..a758bbb1 100644 --- a/deno.lock +++ b/deno.lock @@ -148,7 +148,9 @@ "@nostrify/nostrify@0.27.0-rc.3": { "integrity": "0cd3d26bb0d797e95e74b301efc85f4262bd913df12644ff42494a97a02a6c0d", "dependencies": [ + "jsr:@std/crypto@^0.224.0", "jsr:@std/encoding@^0.224.1", + "npm:@scure/base@^1.1.6", "npm:@scure/bip32@^1.4.0", "npm:@scure/bip39@^1.3.0", "npm:kysely@^0.27.3", diff --git a/src/controllers/api/trends.ts b/src/controllers/api/trends.ts index 76c84f58..d581ddc8 100644 --- a/src/controllers/api/trends.ts +++ b/src/controllers/api/trends.ts @@ -12,8 +12,12 @@ import { renderStatus } from '@/views/mastodon/statuses.ts'; let trendingHashtagsCache = getTrendingHashtags(); Deno.cron('update trending hashtags cache', '35 * * * *', async () => { - const trends = await getTrendingHashtags(); - trendingHashtagsCache = Promise.resolve(trends); + try { + const trends = await getTrendingHashtags(); + trendingHashtagsCache = Promise.resolve(trends); + } catch (e) { + console.error(e); + } }); const trendingTagsQuerySchema = z.object({ @@ -51,8 +55,12 @@ async function getTrendingHashtags() { let trendingLinksCache = getTrendingLinks(); Deno.cron('update trending links cache', '50 * * * *', async () => { - const trends = await getTrendingLinks(); - trendingLinksCache = Promise.resolve(trends); + try { + const trends = await getTrendingLinks(); + trendingLinksCache = Promise.resolve(trends); + } catch (e) { + console.error(e); + } }); const trendingLinksController: AppController = async (c) => {