feat(logs): add --once for bounded non-interactive capture#120
Open
tcerqueira wants to merge 1 commit into
Open
feat(logs): add --once for bounded non-interactive capture#120tcerqueira wants to merge 1 commit into
tcerqueira wants to merge 1 commit into
Conversation
`deno deploy logs` could only tail live forever or stream a fixed --start/--end window; CI and agents had no way to capture the currently-available logs and exit without already knowing an --end (rough edge from #112). --once drains the backfill window and exits 0 at the live boundary (the server's "streaming" phase marker), so the capture is bounded and deterministic. With no --start it defaults to the last hour so there is something to drain; an explicit --start still wins. NDJSON on stdout is preserved and the SSE subscription is closed cleanly before exit. An empty window exits 0 with no output. Also make `logs` read-only like the other inspection commands via config.noCreate(), and fix the long-broken noCreate guard in actionHandler (it tested the always-truthy config wrapper instead of config.config). No command now creates a stray deno.jsonc as a side effect, which in --json mode would otherwise print a non-JSON "Created configuration file" line on stdout. Existing config files are still updated.
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.
What
Adds
--oncetodeno deploy logs: a bounded, non-interactive "capturecurrently-available logs then exit" mode for CI and agents. Addresses the rough
edge from #112 — previously
logscould only tail live forever or stream afixed
--start/--endwindow, with no way to grab the current backlog and exitwithout already knowing an
--end.Semantics
--oncestreams the backfilled logs in the window, then exits0the momentthe backend emits its
"streaming"phase marker (verified empirically: themarker is sent after the backfill batches, signalling the switch from
historical backfill to live tailing). It does not enter live tail.
sub.unsubscribe()) and the process exitscleanly with
ExitCode.OK. A server-completed stream (onStopped, e.g. abounded
--start/--endwindow) is also treated as a clean end-of-capture.--startis given (a barenew Date()start would request an empty window); an explicit--startwidens/narrows it.
--jsonNDJSON discipline is preserved: only log records on stdout, one JSONobject per line. An empty window exits
0with no output.Rejected / deferred alternatives
--timeout <duration>(exit after N seconds of silence): usefulfor bounded live capture, but heuristic and non-deterministic.
--onceusesa real backend signal (backfill-complete), so it's exact. Can be added later as
a complementary flag.
--max <n>lines: orthogonal cap; not needed for the "drain currentbacklog" use case and easily composed downstream (
| head -n).Supporting fix
logsis read-only, so it now callsconfig.noCreate()like the otherinspection commands (
apps,orgs,deployments,whoami). That exposed along-standing bug: the
actionHandlersave guard tested!config(thealways-truthy
Configwrapper) instead of!config.config(no existing configfile), so
noCreate()never actually prevented file creation. Fixed. Neteffect: no command creates a stray
deno.jsoncas a side effect — which in--jsonmode would otherwise print a non-JSONCreated configuration filelineon stdout. Existing config files are still updated.
Verification (live, against a throwaway app)
logs --once --json --non-interactive: exits on its own (~0s), emits cleanNDJSON (all lines parse), no
deno.jsonccreated.--once --start <now>): exits0with no output.--once): exits0, formatted output.deno.jsonis still updated with thedeployobject.
Overlap
Touches the
logscommand region ofdeploy/mod.ts; thetc/app-production-urlsibling PR touches the publish/deploy flow in the same file and will rebase.