mirror of
https://github.com/supermemoryai/supermemory.git
synced 2026-09-12 23:01:07 +00:00
prevent permanent caching of failed OG data fetches
This commit is contained in:
parent
96b826488c
commit
0360066f49
1 changed files with 4 additions and 6 deletions
|
|
@ -74,9 +74,9 @@ type OgData = {
|
|||
}
|
||||
|
||||
const ogCache = new Map<string, OgData>()
|
||||
const ogInflight = new Map<string, Promise<OgData>>()
|
||||
const ogInflight = new Map<string, Promise<OgData | null>>()
|
||||
|
||||
function fetchOgData(url: string): Promise<OgData> {
|
||||
function fetchOgData(url: string): Promise<OgData | null> {
|
||||
const cached = ogCache.get(url)
|
||||
if (cached) return Promise.resolve(cached)
|
||||
|
||||
|
|
@ -95,10 +95,8 @@ function fetchOgData(url: string): Promise<OgData> {
|
|||
return result
|
||||
})
|
||||
.catch(() => {
|
||||
const empty: OgData = {}
|
||||
ogCache.set(url, empty)
|
||||
ogInflight.delete(url)
|
||||
return empty
|
||||
return null
|
||||
})
|
||||
|
||||
ogInflight.set(url, promise)
|
||||
|
|
@ -729,7 +727,7 @@ const DocumentCard = memo(
|
|||
if (needsOgData && !ogData && !isLoadingOg && document.url) {
|
||||
setIsLoadingOg(true)
|
||||
fetchOgData(document.url)
|
||||
.then(setOgData)
|
||||
.then((data) => { if (data) setOgData(data) })
|
||||
.finally(() => setIsLoadingOg(false))
|
||||
}
|
||||
}, [needsOgData, ogData, isLoadingOg, document.url])
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue