diff options
author | Hailey <me@haileyok.com> | 2024-02-27 10:01:29 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-27 10:01:29 -0800 |
commit | c8d02a791a84a243b290b3a1479aa6ac097a51fa (patch) | |
tree | 391831bf7aec2be4ce5c677024c24ec997842759 /src | |
parent | 58aaad704aa971c5ebbf5a5f330a2e2129b557f6 (diff) | |
download | voidsky-c8d02a791a84a243b290b3a1479aa6ac097a51fa.tar.zst |
Log to Sentry whenever users encounter Bluesky feed errors (#2999)
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/constants.ts | 6 | ||||
-rw-r--r-- | src/state/queries/post-feed.ts | 59 |
2 files changed, 47 insertions, 18 deletions
diff --git a/src/lib/constants.ts b/src/lib/constants.ts index c8e5273d4..e86844395 100644 --- a/src/lib/constants.ts +++ b/src/lib/constants.ts @@ -75,3 +75,9 @@ export const HITSLOP_20 = createHitslop(20) export const HITSLOP_30 = createHitslop(30) export const BACK_HITSLOP = HITSLOP_30 export const MAX_POST_LINES = 25 + +export const BSKY_FEED_OWNER_DIDS = [ + 'did:plc:z72i7hdynmk6r22z27h6tvur', + 'did:plc:vpkhqolt662uhesyj6nxm7ys', + 'did:plc:q6gjnaw2blty4crticxkmujt', +] diff --git a/src/state/queries/post-feed.ts b/src/state/queries/post-feed.ts index 40399395a..220aac374 100644 --- a/src/state/queries/post-feed.ts +++ b/src/state/queries/post-feed.ts @@ -1,6 +1,11 @@ import React, {useCallback, useEffect, useRef} from 'react' import {AppState} from 'react-native' -import {AppBskyFeedDefs, AppBskyFeedPost, PostModeration} from '@atproto/api' +import { + AppBskyFeedDefs, + AppBskyFeedPost, + AtUri, + PostModeration, +} from '@atproto/api' import { useInfiniteQuery, InfiniteData, @@ -29,6 +34,7 @@ import {KnownError} from '#/view/com/posts/FeedErrorMessage' import {embedViewRecordToPostView, getEmbeddedPost} from './util' import {useModerationOpts} from './preferences' import {queryClient} from 'lib/react-query' +import {BSKY_FEED_OWNER_DIDS} from 'lib/constants' type ActorDid = string type AuthorFilter = @@ -137,24 +143,41 @@ export function usePostFeedQuery( cursor: undefined, } - const res = await api.fetch({cursor, limit: PAGE_SIZE}) - precacheFeedPostProfiles(queryClient, res.feed) - - /* - * If this is a public view, we need to check if posts fail moderation. - * If all fail, we throw an error. If only some fail, we continue and let - * moderations happen later, which results in some posts being shown and - * some not. - */ - if (!getAgent().session) { - assertSomePostsPassModeration(res.feed) - } + try { + const res = await api.fetch({cursor, limit: PAGE_SIZE}) + precacheFeedPostProfiles(queryClient, res.feed) + + /* + * If this is a public view, we need to check if posts fail moderation. + * If all fail, we throw an error. If only some fail, we continue and let + * moderations happen later, which results in some posts being shown and + * some not. + */ + if (!getAgent().session) { + assertSomePostsPassModeration(res.feed) + } + + return { + api, + cursor: res.cursor, + feed: res.feed, + fetchedAt: Date.now(), + } + } catch (e) { + const feedDescParts = feedDesc.split('|') + const feedOwnerDid = new AtUri(feedDescParts[1]).hostname + + if ( + feedDescParts[0] === 'feedgen' && + BSKY_FEED_OWNER_DIDS.includes(feedOwnerDid) + ) { + logger.error(`Bluesky feed may be offline: ${feedOwnerDid}`, { + feedDesc, + jsError: e, + }) + } - return { - api, - cursor: res.cursor, - feed: res.feed, - fetchedAt: Date.now(), + throw e } }, initialPageParam: undefined, |