mirror of
https://github.com/dergigi/boris.git
synced 2025-12-17 22:54:30 +01:00
chore: remove debug logging from article metadata fetching
- Remove console.log statements from fetchArticleMetadataViaRelays - Remove console.log statements from article-og handler - Keep error logging (console.error) for debugging issues
This commit is contained in:
@@ -29,20 +29,16 @@ export default async function handler(req: VercelRequest, res: VercelResponse) {
|
|||||||
|
|
||||||
if (!meta) {
|
if (!meta) {
|
||||||
// Cache miss: fetch from relays (let it use its natural timeouts)
|
// Cache miss: fetch from relays (let it use its natural timeouts)
|
||||||
console.log(`Cache miss for ${naddr}, fetching from relays...`)
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
meta = await fetchArticleMetadataViaRelays(naddr)
|
meta = await fetchArticleMetadataViaRelays(naddr)
|
||||||
|
|
||||||
if (meta) {
|
if (meta) {
|
||||||
console.log(`Relays found metadata for ${naddr}:`, { title: meta.title, summary: meta.summary?.substring(0, 50) })
|
|
||||||
// Store in Redis and use it
|
// Store in Redis and use it
|
||||||
await setArticleMeta(naddr, meta).catch((err) => {
|
await setArticleMeta(naddr, meta).catch((err) => {
|
||||||
console.error('Failed to cache relay metadata:', err)
|
console.error('Failed to cache relay metadata:', err)
|
||||||
})
|
})
|
||||||
cacheMaxAge = 86400
|
cacheMaxAge = 86400
|
||||||
} else {
|
} else {
|
||||||
console.log(`Relay fetch failed for ${naddr}, using default fallback`)
|
|
||||||
// Relay fetch failed: use default fallback
|
// Relay fetch failed: use default fallback
|
||||||
cacheMaxAge = 300
|
cacheMaxAge = 300
|
||||||
}
|
}
|
||||||
@@ -50,8 +46,6 @@ export default async function handler(req: VercelRequest, res: VercelResponse) {
|
|||||||
console.error(`Error fetching from relays for ${naddr}:`, err)
|
console.error(`Error fetching from relays for ${naddr}:`, err)
|
||||||
cacheMaxAge = 300
|
cacheMaxAge = 300
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
console.log(`Cache hit for ${naddr}:`, { title: meta.title, summary: meta.summary?.substring(0, 50) })
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate and send HTML
|
// Generate and send HTML
|
||||||
|
|||||||
@@ -117,7 +117,6 @@ export async function fetchArticleMetadataViaRelays(naddr: string): Promise<Arti
|
|||||||
const relayUrls = pointer.relays && pointer.relays.length > 0 ? pointer.relays : RELAYS
|
const relayUrls = pointer.relays && pointer.relays.length > 0 ? pointer.relays : RELAYS
|
||||||
|
|
||||||
// Step A: Fetch article - return as soon as first event arrives
|
// Step A: Fetch article - return as soon as first event arrives
|
||||||
console.log(`Fetching article from relays for ${naddr}...`)
|
|
||||||
const article = await fetchFirstEvent(relayPool, relayUrls, {
|
const article = await fetchFirstEvent(relayPool, relayUrls, {
|
||||||
kinds: [pointer.kind],
|
kinds: [pointer.kind],
|
||||||
authors: [pointer.pubkey],
|
authors: [pointer.pubkey],
|
||||||
@@ -125,12 +124,9 @@ export async function fetchArticleMetadataViaRelays(naddr: string): Promise<Arti
|
|||||||
}, 7000)
|
}, 7000)
|
||||||
|
|
||||||
if (!article) {
|
if (!article) {
|
||||||
console.log(`No article found for ${naddr}`)
|
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(`Article found for ${naddr}, extracting metadata...`)
|
|
||||||
|
|
||||||
// Step B: Extract article metadata immediately
|
// Step B: Extract article metadata immediately
|
||||||
const title = getArticleTitle(article) || 'Untitled Article'
|
const title = getArticleTitle(article) || 'Untitled Article'
|
||||||
const summary = getArticleSummary(article) || 'Read this article on Boris'
|
const summary = getArticleSummary(article) || 'Read this article on Boris'
|
||||||
@@ -146,23 +142,17 @@ export async function fetchArticleMetadataViaRelays(naddr: string): Promise<Arti
|
|||||||
const imageAlt = title || 'Article cover image'
|
const imageAlt = title || 'Article cover image'
|
||||||
|
|
||||||
// Step C: Fetch author profile with micro-wait (connections already warm)
|
// Step C: Fetch author profile with micro-wait (connections already warm)
|
||||||
console.log(`Fetching author profile for ${pointer.pubkey.slice(0, 8)}...`)
|
|
||||||
let authorName = await fetchAuthorProfile(relayPool, relayUrls, pointer.pubkey, 400)
|
let authorName = await fetchAuthorProfile(relayPool, relayUrls, pointer.pubkey, 400)
|
||||||
let authorSource = 'profile'
|
|
||||||
|
|
||||||
// Step D: Optional hedge - try again with slightly longer timeout if first attempt failed
|
// Step D: Optional hedge - try again with slightly longer timeout if first attempt failed
|
||||||
if (!authorName) {
|
if (!authorName) {
|
||||||
console.log(`First profile fetch failed, trying hedge...`)
|
|
||||||
authorName = await fetchAuthorProfile(relayPool, relayUrls, pointer.pubkey, 600)
|
authorName = await fetchAuthorProfile(relayPool, relayUrls, pointer.pubkey, 600)
|
||||||
authorSource = authorName ? 'profile-hedge' : 'fallback'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!authorName) {
|
if (!authorName) {
|
||||||
authorName = pointer.pubkey.slice(0, 8) + '...'
|
authorName = pointer.pubkey.slice(0, 8) + '...'
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(`Author resolved via ${authorSource}: ${authorName}`)
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
title,
|
title,
|
||||||
summary,
|
summary,
|
||||||
|
|||||||
Reference in New Issue
Block a user