mirror of
https://github.com/dergigi/boris.git
synced 2025-12-17 14:44:26 +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) {
|
||||
// Cache miss: fetch from relays (let it use its natural timeouts)
|
||||
console.log(`Cache miss for ${naddr}, fetching from relays...`)
|
||||
|
||||
try {
|
||||
meta = await fetchArticleMetadataViaRelays(naddr)
|
||||
|
||||
if (meta) {
|
||||
console.log(`Relays found metadata for ${naddr}:`, { title: meta.title, summary: meta.summary?.substring(0, 50) })
|
||||
// Store in Redis and use it
|
||||
await setArticleMeta(naddr, meta).catch((err) => {
|
||||
console.error('Failed to cache relay metadata:', err)
|
||||
})
|
||||
cacheMaxAge = 86400
|
||||
} else {
|
||||
console.log(`Relay fetch failed for ${naddr}, using default fallback`)
|
||||
// Relay fetch failed: use default fallback
|
||||
cacheMaxAge = 300
|
||||
}
|
||||
@@ -50,8 +46,6 @@ export default async function handler(req: VercelRequest, res: VercelResponse) {
|
||||
console.error(`Error fetching from relays for ${naddr}:`, err)
|
||||
cacheMaxAge = 300
|
||||
}
|
||||
} else {
|
||||
console.log(`Cache hit for ${naddr}:`, { title: meta.title, summary: meta.summary?.substring(0, 50) })
|
||||
}
|
||||
|
||||
// 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
|
||||
|
||||
// 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, {
|
||||
kinds: [pointer.kind],
|
||||
authors: [pointer.pubkey],
|
||||
@@ -125,12 +124,9 @@ export async function fetchArticleMetadataViaRelays(naddr: string): Promise<Arti
|
||||
}, 7000)
|
||||
|
||||
if (!article) {
|
||||
console.log(`No article found for ${naddr}`)
|
||||
return null
|
||||
}
|
||||
|
||||
console.log(`Article found for ${naddr}, extracting metadata...`)
|
||||
|
||||
// Step B: Extract article metadata immediately
|
||||
const title = getArticleTitle(article) || 'Untitled Article'
|
||||
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'
|
||||
|
||||
// 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 authorSource = 'profile'
|
||||
|
||||
// Step D: Optional hedge - try again with slightly longer timeout if first attempt failed
|
||||
if (!authorName) {
|
||||
console.log(`First profile fetch failed, trying hedge...`)
|
||||
authorName = await fetchAuthorProfile(relayPool, relayUrls, pointer.pubkey, 600)
|
||||
authorSource = authorName ? 'profile-hedge' : 'fallback'
|
||||
}
|
||||
|
||||
if (!authorName) {
|
||||
authorName = pointer.pubkey.slice(0, 8) + '...'
|
||||
}
|
||||
|
||||
console.log(`Author resolved via ${authorSource}: ${authorName}`)
|
||||
|
||||
return {
|
||||
title,
|
||||
summary,
|
||||
|
||||
Reference in New Issue
Block a user