From 8249966d6f55b06c6f7a6340693b068a89058327 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Thu, 3 Dec 2026 21:57:12 -0700 Subject: feed: every relay ask ends at its maxWait, and crawlers wait up to 7.5 s. Measured after a restart: a link-preview crawler still got the plain page after 6 s, because nostr-tools starts maxWait only once a socket is open and a relay slow to connect held the build open. query() now stops at maxWait from the ask itself; a cold post page built for TelegramBot in 3.7 s (was over 6 s), a browser still gets its page at 0.65 s. BOT_BUDGET_MS 7.5 s covers a reply's three rounds (2.5 + 2.5 + 2 s); nginx on cs allows the note/profile routes 10 s (was 3 s, which cut crawlers short). Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01VMan6WoqaQDYdpWkatPCar (feed copy, same as coinosv3-server) --- feed/note-page.js | 2 +- feed/server.js | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/feed/note-page.js b/feed/note-page.js index ac51f77..36f54fd 100644 --- a/feed/note-page.js +++ b/feed/note-page.js @@ -22,7 +22,7 @@ const BUDGET_MS = 500; // A link-preview crawler reads the page once and keeps that card (Telegram, // 2026-12-04: a fresh post shared at once got the site's card because its // thread took longer than BUDGET_MS); it can wait for the real thing. -export const BOT_BUDGET_MS = 6000; +export const BOT_BUDGET_MS = 7500; // a reply's thread: 2.5 s + 2.5 s + 2 s of relay asks export const isPreviewBot = (ua) => /bot\b|bot\/|crawler|spider|facebookexternalhit|facebookcatalog|whatsapp|telegram|slack|discord|twitter|linkedin|skype|embedly|iframely|mastodon|pleroma|misskey|akkoma|signal|vkshare|redditbot|applebot|bingpreview|google|yandex|duckduck|pinterest|tumblr|snapchat|preview/i.test(String(ua || '')); const FRESH_MS = 60_000; // a thread younger than this is served as is const KEEP_MS = 6 * 3600_000; // older, it's still served while a refresh runs diff --git a/feed/server.js b/feed/server.js index 9566447..cc97d8b 100644 --- a/feed/server.js +++ b/feed/server.js @@ -25,6 +25,9 @@ const query = (relays, filter, maxWait, { idle = 0 } = {}) => new Promise((resol onclose: finish, }); if (done) try { sub.close(); } catch {} + // maxWait starts only once a socket is open: a relay that's slow to connect + // (every socket is cold after a restart) held builds past 6 s. A hard stop. + setTimeout(finish, maxWait); }); const threads = createThreadCache({ build: (ref) => buildThread(ref, query) }); const primal = createPrimal(); -- cgit v1.2.3