Refactor error handling in WorkerService and SDKAgent

- Removed unnecessary logging for aborted sessions in WorkerService.
- Simplified the finally block in WorkerService by removing crash recovery logging.
- Cleaned up the try-catch structure in SDKAgent's startSession method, removing redundant error handling.
This commit is contained in:
Alex Newman
2026-01-01 20:46:39 -05:00
parent 564249f533
commit c2fbb39fd0
3 changed files with 8 additions and 30 deletions
+5 -12
View File
@@ -41,7 +41,10 @@ export class SDKAgent {
* @param worker WorkerService reference for spinner control (optional)
*/
async startSession(session: ActiveSession, worker?: any): Promise<void> {
try {
// Find Claude executable
const claudePath = this.findClaudeExecutable();
@@ -183,18 +186,8 @@ export class SDKAgent {
duration: `${(sessionDuration / 1000).toFixed(1)}s`
});
} catch (error: any) {
if (error.name === 'AbortError') {
logger.warn('SDK', 'Agent aborted', { sessionId: session.sessionDbId });
} else {
logger.failure('SDK', 'Agent error', { sessionDbId: session.sessionDbId }, error);
}
throw error;
} finally {
// NOTE: Do NOT delete session here - SessionRoutes.finally() handles cleanup
// and auto-restart logic. Deleting here races with pending work checks.
}
}
/**
* Create event-driven message generator (yields messages from SessionManager)