Repository navigation
fix(sandbox): chunk dep-install log lines to survive the log pipeline - #4273
Merged
Merged
Conversation
Third and final format for the dep-install telemetry. Both prior shapes were destroyed by the log pipeline in prod: - one line with the whole dependencies array → truncated at 16KB → unparseable JSON (VictoriaLogs extracts nothing); - one line per dep (#4271) → ~350-line burst per install → the collector's rate sampler drops ~99% (survivors tagged sample_rate=100), leaving 2-4 random transitive deps per install. Emit chunked sandbox.deps lines of ~200 name@version strings (~7KB each, 1-3 lines per install): under the truncation cap AND under the burst sampler. The deps field is a pre-JSON-encoded string so no pipeline stage can flatten the array; VictoriaLogs `unroll (deps)` parses it back into per-dep rows — verified end-to-end against the live datasource with an inserted probe line.
pedrofrxncx
enabled auto-merge (squash)
July 2, 2026 22:00
Contributor
There was a problem hiding this comment.
1 issue found across 2 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="packages/sandbox/daemon/setup/dep-metrics.ts">
<violation number="1" location="packages/sandbox/daemon/setup/dep-metrics.ts:88">
P2: Large installs can still emit truncation-prone lines because chunking is based on dependency count, not serialized byte length. Consider building chunks by `Buffer.byteLength(JSON.stringify(chunk))` (with a safety margin under 16KB) so every emitted line stays parseable.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
pedrofrxncx
disabled auto-merge
July 2, 2026 22:03
Count-based chunking (200/line) doesn't bound the serialized line size: npm names allow up to 214 chars, so a line could reach ~40KB and hit the same 16KB truncation this format exists to avoid. Pack name@version strings greedily by Buffer.byteLength under a 14KB cap (leaving ~2KB for the JSON envelope). Adds a regression test with 200 long-named deps.
pedrofrxncx
enabled auto-merge (squash)
July 2, 2026 22:07
Contributor
There was a problem hiding this comment.
1 issue found across 2 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
pedrofrxncx
disabled auto-merge
July 2, 2026 22:09
The chunker sized the raw deps array, but deps is stored as a string field
so the outer JSON.stringify escapes every element's quotes ("x" -> \"x\",
+2 bytes each). Short-dep-heavy lines undercounted by ~2 bytes/dep could
cross 16KB and truncate. Budget the FINAL line: measured envelope + per-dep
escaped cost, cap 15.5KB. Adds a 4000-short-dep regression test.
decocms Bot
pushed a commit
that referenced
this pull request
Jul 2, 2026
PR: #4273 fix(sandbox): chunk dep-install log lines to survive the log pipeline Bump type: patch - @decocms/sandbox (packages/sandbox/package.json): 1.9.1 -> 1.9.2 Deploy-Scope: both
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.
Problem — both prior formats are destroyed by the log pipeline (observed in prod)
sample_rate=100). Real installs surfaced as 2-4 random transitive deps — noise, not a ranking.Fix — chunked lines that dodge both walls
Emit
msg: "sandbox.deps"lines of ~200name@versionstrings each (~7KB → under truncation; 1-3 lines/install → under the burst sampler), each carryingchunk/chunks/dependencyCount+ install context. Thedepsfield is a pre-JSON-encoded string, not a real array, so no pipeline stage can flatten or re-shape it.Verified against live infra, not theory
Inserted a probe line in this exact format into the VictoriaLogs datasource and ran the panel query:
→ returns one row per package (
[email protected],[email protected],[email protected]). The Grafana panel is wired to this query and will populate as sandboxes install after this rolls (image release + deco-apps-cd bump are automatic since #4272).Testing
buildDepLines): 391 deps → 2 lines, each <16KB, all deps present exactly once, parseable; zero-dep install still emits 1 countable line.bun test daemon/setup/dep-metrics.test.ts: 4 pass.bun run fmtclean; no new type errors.🤖 Generated with Claude Code
Summary by cubic
Chunk dependency-install telemetry into byte-bounded JSON log lines and cap the final serialized line at 15.5KB (including deps-string escaping) to survive the log pipeline and restore reliable dependency metrics in VictoriaLogs/Grafana. Replaces the broken single-array and per-dep formats.
sandbox.depslines with final bytes ≤15.5KB to avoid 16KB truncation and burst sampling; greedily packname@versionentries byBuffer.byteLength.buildDepLinesand tests for long-name deps, thousands of short deps (quote-escaping accounted), large installs, and zero-dep installs.Written for commit 6d7d0f6. Summary will update on new commits.