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
-15
View File
@@ -747,25 +747,10 @@ export class WorkerService {
session.generatorPromise = this.sdkAgent.startSession(session, this)
.catch(error => {
// Only log if not aborted
if (session.abortController.signal.aborted) return;
logger.error('SYSTEM', `Generator failed (${source})`, {
sessionId: sid,
error: error.message
}, error);
})
.finally(() => {
session.generatorPromise = null;
this.broadcastProcessingStatus();
// Crash recovery: if not aborted, check if we should restart
if (!session.abortController.signal.aborted) {
// We can check if there are pending messages to decide if restart is urgent
// But generally, if it crashed, we might want to restart?
// For now, let's just log. The user/system can trigger restart if needed.
logger.warn('SYSTEM', `Session processor exited unexpectedly`, { sessionId: sid });
}
});
}