Repository navigation
feat(sandbox): make the Go daemon the default for every sandbox - #5568
Merged
Merged
Conversation
pedrofrxncx
enabled auto-merge (squash)
August 2, 2026 15:40
Contributor
There was a problem hiding this comment.
No issues found across 6 files
You’re at about 90% of the monthly reviewed-line limit. You may want to disable incremental reviews to conserve quota. Reviews will continue until that limit is exceeded. If you need help avoiding interruptions, please contact [email protected].
decocms Bot
pushed a commit
that referenced
this pull request
Aug 2, 2026
PR: #5568 feat(sandbox): make the Go daemon the default for every sandbox Bump type: minor - decocms (apps/api/package.json): 4.158.9 -> 4.159.0 - @decocms/native (apps/native/package.json): 4.158.9 -> 4.159.0 - @decocms/shared (packages/shared/package.json): 0.12.0 -> 0.13.0 Deploy-Scope: server
This was referenced Aug 2, 2026
guitavano
added a commit
that referenced
this pull request
Aug 4, 2026
…5676) * fix(sandbox): restore port-sniffer phrase gate + cross-chunk carry The Go daemon's port sniffer (default since #5568, TS daemon deleted in #5575) was an incomplete port of the TypeScript one: it dropped two safeguards, so a Vite dev server that binds a non-config port (e.g. 5173) is no longer detected. `getDevPort()` then falls back to the configured `application.port` (3000) — the daemon proxies/probes 127.0.0.1:3000, gets connection-refused forever, serves "Server is starting…" and never leaves the `starting` lifecycle phase. The preview is stuck on the boot skeleton even though `vite dev` is ready. Restore both safeguards from the TS sniffer: - **Phrase gate.** The bind URL must be preceded by `Local:` / `Listening on` on the same line. Without it, a bare `http://localhost:3000` line (a framework echoing the injected PORT, a proxied fetch, a sibling process) hijacks the lock before Vite's real `Local: http://localhost:5173/`. - **Cross-chunk carry.** PTY reads aren't line-buffered, so the bind line can split across chunks. Carry a bounded, ANSI-stripped tail per source and match the concatenation. Also require a `/` or whitespace after the port so a split mid-number ("...:51" | "73/") waits instead of locking the truncated "51". Tests cover both failure modes (bare-3000 hijack, split bind line). Co-Authored-By: Claude Opus 4.8 <[email protected]> * fix(sandbox): lock on any non-digit terminator, consume ANSI ESC Review of the previous commit found the `[/\s]` trailing requirement regressed the no-trailing-slash frameworks (next, bun) it claimed to support: the ANSI stripper matches the bracket body but not the ESC, so a colored `http://localhost:3000\x1b[0m\n` strips to `...:3000\x1b\n` — the ESC sits between the port and the newline, `[/\s]` rejects it, and the port is never sniffed (silently falling back to the wrong configured port — the exact failure the sniffer exists to prevent). - Require a non-digit terminator (`[^\d]`) instead of `[/\s]`. Still fixes the mid-number split (a buffer ending on digits has no following char → waits), but locks on any non-digit — `/`, `)`, `,`, whitespace, newline, or a leftover ESC — matching the eager TS behavior for the frameworks a strict `[/\s]` would have dropped. - Make ansiPattern consume the ESC when present (`\x1b?`) so a stripped color code leaves nothing between the port and its terminator. Tests: colored no-trailing-slash, non-slash terminator, Reset clears carry, sibling URL before the banner (line-bound `[^\n]*?`), and per-source carry isolation. Co-Authored-By: Claude Opus 4.8 <[email protected]> --------- Co-authored-by: Claude Opus 4.8 <[email protected]>
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
Flips
resolveDaemonImplso a sandbox lands on the Go daemon unless something explicitly says otherwise. One line of behavior; the rest is the comments and tests that asserted the old direction.resolve-daemon-impl.ts:flags?.sandbox_go_daemon ? "go" : "ts"→flags?.sandbox_go_daemon === false ? "ts" : "go". Precedence is unchanged (prop → org flag → default); only the default and the flag's polarity move.sandbox_go_daemonbecomes an opt-out: absent/unset/true→ Go, explicitfalse→ TS. Schema description updated to say so. No rename — the flag name still reads correctly, and renaming it would orphan whatever rows already set it.SANDBOX_START'sdaemonImplprop is untouched and still wins in both directions, so a single sandbox can be pinned back totswithout opting the org out.lifecycle.tsandstart.tsthat described Go as an opt-in rollout.Rollback
Three levels, cheapest first:
SANDBOX_START { daemonImpl: "ts" }.ORGANIZATION_SETTINGS_UPDATE { flags: { sandbox_go_daemon: false } }.STUDIO_SANDBOX_GO_TEMPLATE_NAMEin the studio chart.resolveClaimTemplatecollapses everygoback totswhen there's no Go SandboxTemplate to point a claim at, so the whole fleet reverts on the next claim with no code deploy. Live sandboxes always drain on the binary they booted with.Depends on
decocms/deco-apps-cd#191 must merge and sync first. It KEDA-scales the
studio-sandbox-{stg,prod}-gowarm pools. Without it those pools are canary-sized at a static 1 replica while KEDA scales only the TS pools — this change would send the whole fleet at a 1-pod pool and cold-start most sandboxes.Testing
bun teston the three affected files — 32 pass. Inverted the existing assertions rather than appending:resolve-daemon-impl.test.ts: "defaults to ts" → "defaults to go"; "honors the org flag" → "treats the org flag as an opt-out"; the explicit-prop case now pinstswith no flag set, which is the escape hatch that matters once Go is the default.start.test.ts: the twodaemonImplreaching-runner.ensurecases swapped, and the "pin inside a flagged org" case became "pin without opting the org out".claim-template.test.tsneeded no change —resolveClaimTemplateis downstream of this and its contract (no Go template ⇒ts) is unchanged.bun run fmt,bun run lint(0 errors) clean.generate:tool-contractsproduced no diff for this change — the flag description doesn't reachtool-io.ts.Caveat worth a second opinion
The prod Go canary has been up ~31h with essentially no real traffic through it — 2 pods, both warm-pool, and no Go
SandboxClaimlive at the time I checked. So this flip is the first meaningful Go traffic in prod rather than a graduation from a proven canary. The three rollback levels above are why I think that's acceptable, but if you'd rather bake stg first, merge decocms/deco-apps-cd#191, then hold this and flip a couple of orgs'sandbox_go_daemonby hand for a day.Summary by cubic
Makes the Go sandbox daemon the default for all new sandboxes. The
sandbox_go_daemonflag is now an opt-out (falsepins TS), andSANDBOX_START’sdaemonImplstill overrides per sandbox.Migration
SANDBOX_START { daemonImpl: "ts" }.flags.sandbox_go_daemon = false.STUDIO_SANDBOX_GO_TEMPLATE_NAMEto route new claims to TS; live sandboxes drain on their boot binary.Dependencies
decocms/deco-apps-cd#191must merge and sync first to scalestudio-sandbox-{stg,prod}-gowarm pools.Written for commit f999e8d. Summary will update on new commits.