Skip to content

Commit

Permalink
Merge pull request #589 from dappforce/deploy/revalidate
Browse files Browse the repository at this point in the history
Add try catch to update user id
  • Loading branch information
olehmell authored Mar 12, 2024
2 parents e9ae083 + dee3023 commit 0a11262
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
12 changes: 7 additions & 5 deletions src/pages/api/posts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,13 @@ export async function getPostsServer(postIds: string[]): Promise<PostData[]> {
// link fetching itself has timeout of 20_000, but for data fetching, it faster timeout
// if it needs more than 8s, the post fetching is not delayed, but it will still be fetched and put to redis
// so that in the next fetch, it will have the correct data from the redis
setTimeout(() => {
throw new Error('Link metadata fetching timeout')
}, 8_000)
const metadata = await getLinkMetadata(link)
if (metadata) metadataMap[link] = metadata
try {
setTimeout(() => {
throw new Error('Link metadata fetching timeout')
}, 8_000)
const metadata = await getLinkMetadata(link)
if (metadata) metadataMap[link] = metadata
} catch {}
})
await Promise.allSettled(metadataPromises)

Expand Down
10 changes: 7 additions & 3 deletions src/stores/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,13 @@ const useAnalyticsBase = create<State & Actions>()((set, get) => {
_updateUserId: async (address: string | undefined) => {
const { amp } = get()
if (address) {
const userId = await createUserId(address)
amp?.setUserId(userId)
set({ userId })
try {
const userId = await createUserId(address)
amp?.setUserId(userId)
set({ userId })
} catch (err) {
console.error('Error creating user id', err)
}
} else {
amp?.setUserId(undefined)
set({ userId: undefined })
Expand Down

0 comments on commit 0a11262

Please sign in to comment.