fix(sandbox): flag single-task kill()/killAll() as intentional#4515
Open
pedrofrxncx wants to merge 1 commit into
Open
fix(sandbox): flag single-task kill()/killAll() as intentional#4515pedrofrxncx wants to merge 1 commit into
pedrofrxncx wants to merge 1 commit into
Conversation
TaskManager.kill(id) and killAll() never set task.intentional, unlike
killByLogName({intentional: true}). Both are only ever called from
deliberate Stop routes (POST /_sandbox/tasks/:id/kill and
/tasks/kill-all), so a stopped WELL_KNOWN_STARTERS (dev script) task
would have its exit misread by SetupOrchestrator's onTaskExit as a
crash, wedging the daemon into status=error/phase=start-failed instead
of respecting the deliberate stop.
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.
Source
A bug found reading
packages/sandbox/daemon/process/task-manager.ts(in the recently-changed hunting ground).The bug
TaskManager.kill(id, signal)(backsPOST /_sandbox/tasks/:id/kill) andkillAll()(backsPOST /_sandbox/tasks/kill-all) never settask.intentional = true, unlikekillByLogName({ intentional: true })(backsPOST /_sandbox/exec/:name/kill, the dev-server Stop button). Theintentionalfield's own docs say it should cover "orchestrator-driven stop, replace-by-logName, or user Stop" — but the generic single-task/kill-all Stop routes are the only callers ofkill()/killAll(), so every call through them is exactly that "user Stop" case, and it was never flagged.Failure scenario
SetupOrchestrator'sonTaskExithandler (setup/orchestrator.ts:81-106) treats any non-intentional exit of aWELL_KNOWN_STARTERStask (the dev script) as a crash: it setsstatus: "error"and transitions the lifecycle tostart-failed, which surfaces as a stuck error banner requiring manual retry. If a dev-script task is stopped via the generic/tasks/:id/killor/tasks/kill-allroutes instead of the dev-server-specific/exec/:name/killroute, this deliberate stop gets misclassified as a crash.Fix
Set
t.intentional = truein bothkill()andkillAll(), matching the existingkillByLogNamebehavior.Regression test
Added two tests to
task-manager.test.tsassertingintentional === trueafterkill()and afterkillAll()— both fail on the old code (flag staysundefined/false) and pass with the fix.Verification
bun test packages/sandbox/daemon/process/task-manager.test.ts— 11 pass, 0 fail (including the 2 new tests)cd packages/sandbox && bunx tsc --noEmit— cleanbun run fmt— cleanFull CI will run the broader suite.
Summary by cubic
Flagged
TaskManager.kill()andkillAll()as intentional stops so user-initiated stops aren’t misread as crashes. Aligns behavior withkillByLogName()and fixes erroneous error states in the orchestrator.t.intentional = trueinkill()andkillAll()(routes:POST /_sandbox/tasks/:id/kill,POST /_sandbox/tasks/kill-all) to prevent dev-script tasks from being marked as crashed by the orchestrator.packages/sandbox/daemon/process/task-manager.test.tsto assertintentional === trueafterkill()andkillAll().Written for commit 27a300e. Summary will update on new commits.