{"record":{"id":"5a1737692ce50306","repo":"can1357/oh-my-pi","slug":"aborted-before-execution","errorCode":null,"errorMessage":"Aborted before execution","messagePattern":"Aborted before execution","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"info","filePath":"packages/coding-agent/src/modes/controllers/tan-command-controller.ts","lineNumber":123,"sourceCode":"\t\tconst cloneFile = path.join(sessionDir, `${cloneId}.jsonl`);\n\t\tconst label = `/tan ${previewWork(trimmedWork)}`;\n\n\t\tawait this.ctx.sessionManager.ensureOnDisk();\n\t\tawait this.ctx.sessionManager.flush();\n\n\t\tlet jobId = \"\";\n\t\ttry {\n\t\t\tconst cloneManager = await SessionManager.forkFrom(parentFile, cwd, sessionDir, undefined, {\n\t\t\t\tcopyArtifacts: false,\n\t\t\t\tsuppressBreadcrumb: true,\n\t\t\t\tsessionFile: cloneFile,\n\t\t\t});\n\n\t\t\tjobId = manager.register(\n\t\t\t\t\"task\",\n\t\t\t\tlabel,\n\t\t\t\tasync ({ signal }) => {\n\t\t\t\t\tif (signal.aborted) throw new Error(\"Aborted before execution\");\n\n\t\t\t\t\tlet clone: AgentSession | undefined;\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst created = await sdk.createAgentSession({\n\t\t\t\t\t\t\tcwd,\n\t\t\t\t\t\t\tsessionManager: cloneManager,\n\t\t\t\t\t\t\tmodel,\n\t\t\t\t\t\t\tthinkingLevel,\n\t\t\t\t\t\t\tsystemPrompt,\n\t\t\t\t\t\t\ttoolNames,\n\t\t\t\t\t\t\tproviderSessionId: `${parentSessionId}:tan:${Snowflake.next()}`,\n\t\t\t\t\t\t\tproviderPromptCacheKey: parentPromptCacheKey,\n\t\t\t\t\t\t\tmodelRegistry,\n\t\t\t\t\t\t\tauthStorage: modelRegistry.authStorage,\n\t\t\t\t\t\t\tsettings,\n\t\t\t\t\t\t\thasUI: false,\n\t\t\t\t\t\t\tenableMCP: false,\n\t\t\t\t\t\t\tcustomTools,","sourceCodeStart":105,"sourceCodeEnd":141,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/modes/controllers/tan-command-controller.ts#L105-L141","documentation":"The tangential-command job registered with the background task manager checks the AbortSignal at the top of its task callback and throws immediately if abort was requested before any work started. This prevents spawning a whole clone agent session for a task whose cancellation already fired.","triggerScenarios":"Calling start() on TanCommandController, the job being queued/registered via manager.register, and the signal aborting between registration and the callback actually running — the callback's first statement sees signal.aborted === true.","commonSituations":"User cancels the /tan command (Esc) right as it starts; a queued task is aborted while waiting for a concurrency slot; the task manager aborts all jobs during shutdown or session switch.","solutions":["Expected cancellation path — no fix needed; the UI treats it as 'task aborted'","If it fires spuriously, check whether something reuses/aborts the same AbortController too early (e.g. parent controller teardown)","Delay registering the task until you are sure the user did not cancel (e.g. after confirmation)"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if (signal?.aborted) {\n  return; // don't register the task at all\n}","typeGuard":null,"tryCatchPattern":"try {\n  await tanCommand.start(args);\n} catch (err) {\n  if (err.message === \"Aborted before execution\") {\n    // expected cancellation — no-op / show 'cancelled'\n    return;\n  }\n  throw err;\n}","preventionTips":["Check signal.aborted before registering background work","Reuse one AbortController per command lifecycle and don't abort it during setup","Treat this error as a normal cancellation outcome in UI code","Keep task setup fast to shrink the cancellation race window"],"tags":["abort","cancellation","background-task"],"backgroundTag":"aborted-before-execution","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}