Repository navigation
fix(runtime): flush tracked stdout/stderr before exit after run - #348
Merged
Merged
Conversation
hopelynd
added a commit
that referenced
this pull request
Nov 27, 2026
Resolve the conflict in packages/core/src/telemetry/sink.ts between PR #348 (await in-flight local JSONL writes) and PR #349 (per-site Tracker map): - Keep both state holders: inflightLocalWrites (from #348) and remoteBySite (from #349). Drop remoteClient / remoteInitialized, which initRemoteForSite() fully replaced and nothing references. - flushTelemetry() drains _sendAll() on every site tracker, then waits on local writes and remote sends under the same budget; only remote work is abortable on timeout. - Merge both doc-comment variants into one accurate description. Verified: vp check (0 errors), 101 core telemetry tests, 65 runtime flush/exit/telemetry-stage tests.
3 tasks done
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.
Summary
process.exit, including error and interrupt paths, so large piped JSON is not silently cut at ~64KBDescription
Product entries (
bl/kscli) now go throughrunToExit, which installs write tracking, awaitsrun(), flushes pending writes, then exits. Emptywrite("")drain is unreliable on Bun when stdout is a pipe, so each real write's callback is the completion signal, with a timeout fallback.handleErrorand the default SIGINT path also flush before exit (500ms on interrupt). A second SIGINT during that flush exits immediately. Flush timeout returns a boolean and writes a stderr warning viawriteSync(2, …)so agents can observe truncation risk without flipping a successful exit code.This is an alternative to #306: same exit-after-run direction, with Bun-safe flushing and coverage for Node/Bun piped large stdout. Update-check registry / failed-check backoff from #294 are left for follow-up PRs—please use
Refs #294semantics rather than closing the whole issue solely via this change.