mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2026-08-10 00:16:59 +00:00
The fetchAll/fetchAllWithHooks accessories wrapped their whole collection loop in one withTimeoutOrNull, so a relay actively streaming a large backlog was cropped mid-delivery the moment the absolute deadline hit — even though the loop already has proper terminal conditions (per-relay EOSE / CLOSED / cannot-connect) and the timeout's only real job is stall detection. timeoutMs now measures the delta since the LAST message: every event or terminal signal resets the window (fetchAll gains a conflated activity ping so event progress is visible to its wait loop), and only a full window of silence ends the fetch early. fetchFirst/count keep absolute waits (single-response — idle and absolute coincide), and subscribe's duration timeout stays absolute by design (a live stream has no terminal state). Since the pages/pool helpers delegate to fetchAll, pagination inherits the semantics. This also changes app-side callers of these accessories — in their favor: the timeout only ever fired on slow relays, exactly when cropping loses data. New commonTest suite pins the behavior: a relay emitting every 200ms under a 300ms window streams to completion (10/10 events); a stall ends one window after the last message, not after the start; EOSE still returns immediately. CLI docs reworded (--timeout = idle window). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CP4kfLCa3wWtE8Khy21Pkj