refactor(logs): one give-up budget for a --follow stream, not two - #611
Open
davidsu wants to merge 1 commit into
Open
refactor(logs): one give-up budget for a --follow stream, not two#611davidsu wants to merge 1 commit into
davidsu wants to merge 1 commit into
Conversation
The follow path counted failure twice. The connect ladder counted "couldn't open a stream" with a limit of five attempts and a lifetime of one call, so it forgot everything between reconnects. dropsSinceLastEvent counted "opened one and got nothing out of it" with a limit of two and a lifetime of the whole session. Neither knew about the other, and after the fail-fast change both ended the command the same way -- so the two limits bought nothing and disagreed in both directions: the ladder could end a tail while the drop budget still held a spare life, and a backend that alternated the two failures could keep the CLI reconnecting forever because each counter kept being reset by the other's kind of failure. One counter now. A strike is any attempt that produced no logs, whether it failed to connect or connected and delivered nothing. The ladder doubles as the limit, connectWithinStrikes continues the caller's budget instead of starting a fresh one, and a server-side rollover still wipes it. A stream that proved itself alive costs one strike, never a clean slate, so a flapping backend cannot spin here indefinitely. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Contributor
🚀 Package Preview Available!Install this PR's preview build with npm: npm i @base44-preview/cli@0.1.12-pr.611.23d31b2Prefer not to change any import paths? Install using npm alias so your code still imports npm i "base44@npm:@base44-preview/cli@0.1.12-pr.611.23d31b2"Or add it to your {
"dependencies": {
"base44": "npm:@base44-preview/cli@0.1.12-pr.611.23d31b2"
}
}
Preview published to npm registry — try new features instantly! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note
Description
base44 logs --followtracked streaming failure in two independent counters: a connect-retry ladder (CONNECT_RETRY_DELAYS_MS, reset on every call) and a dead-stream budget (dropsSinceLastEvent, capped at 2 for the whole session). Since #595 made both give-up paths end the command identically, the split bought nothing and disagreed in both directions — the ladder could end a tail while the drop budget still held a spare life, and a backend alternating the two failure kinds could keep the CLI reconnecting forever because each counter was reset by the other's failure. This collapses them into a singlestrikesbudget, where a strike is any attempt that produced no logs.Related Issue
Follow-up to #595 (
feat(logs): true realtime --follow via apper SSE stream). No linked issue.Type of Change
Changes Made
dropsSinceLastEventwith a singlestrikescounter shared by both failure kinds (failed connect, and stream that opened then delivered nothing).RECONNECT_DELAYS_MS([1s, 2s, 4s, 8s]) now doubles as both the backoff ladder and the give-up limit viahasRunOutOfStrikes().connectWhileTransientlyUnavailable→connectWithinStrikes(filters, strikes): continues the caller's budget instead of starting a fresh one, and returns the strikes it spent sostreamUntilExhaustedcarries them forward.Reconnectedresult type (stream|refused|exhausted) so an exhausted budget is distinguishable from a refusing backend.strikesAfter(ending, strikes): a server-side rollover (event: end,retriable: true) wipes the budget to zero; a stream that proved itself alive (a row or a keepalive) costs exactly one strike rather than earning a clean slate, so a flapping backend can't spin indefinitely.STREAM_RECONNECT_DELAY_MS.MAX_DROPS_SINCE_LAST_EVENT,STREAM_RECONNECT_DELAY_MS,countDropTowardGivingUp,shouldGiveUpStreaming,connectWhileTransientlyUnavailable, and the now-unusedLogStreamAttemptimport.tests/cli/logs.spec.ts's "stream drop budget" suite as "stream give-up budget" against the new helpers, adding cases for a budget shared across failure kinds and for rollover wiping it.Testing
npm test)Checklist
docs/(AGENTS.md) if I made architectural changesAdditional Notes
Observable behaviour changes, all inside the
--followreconnect loop:KEEPALIVE_SECONDS) and a multi-pod rolling deploy could otherwise burn the cap of 2.Naming intentionally reads as prose (
hasRunOutOfStrikes,ONE_STRIKE_FOR_A_STREAM_THAT_WORKED) to keep the retry policy legible at the call site. No file underdocs/describes this internal retry policy, so none needed updating.strikesAfter/hasRunOutOfStrikes).🤖 Generated by Claude | 2026-08-31 10:55 UTC | 90f0255