diff --git a/agents/src/llm/fallback_adapter.ts b/agents/src/llm/fallback_adapter.ts index 128c2392c..2c4c04da3 100644 --- a/agents/src/llm/fallback_adapter.ts +++ b/agents/src/llm/fallback_adapter.ts @@ -241,7 +241,7 @@ class FallbackLLMStream extends LLMStream { } // Handle timeout errors - if (error instanceof Error && error.name === 'AbortError') { + if ((error as { name?: string })?.name === 'AbortError') { if (checkRecovery) { this._log.warn({ llm: llm.label() }, 'recovery timed out'); } else { diff --git a/agents/src/voice/agent_activity.ts b/agents/src/voice/agent_activity.ts index 21a6a9fac..3279af680 100644 --- a/agents/src/voice/agent_activity.ts +++ b/agents/src/voice/agent_activity.ts @@ -1608,7 +1608,7 @@ export class AgentActivity implements RecognitionHooks { const onAbort = () => waitInactiveTask.cancel(); signal.addEventListener('abort', onAbort, { once: true }); const waitInactiveResult = waitInactiveTask.result.catch((error) => { - if (error instanceof Error && error.name === 'AbortError') { + if ((error as { name?: string })?.name === 'AbortError') { return; } throw error; diff --git a/agents/src/voice/audio_recognition.ts b/agents/src/voice/audio_recognition.ts index dfa72de1d..26d9865c7 100644 --- a/agents/src/voice/audio_recognition.ts +++ b/agents/src/voice/audio_recognition.ts @@ -1729,8 +1729,8 @@ export class AudioRecognition { this.logger.debug('EOU detection task completed'); }) .catch((err: unknown) => { - if (err instanceof Error && err.name === 'AbortError') { - // ignore aborted errors + if ((err as { name?: string })?.name === 'AbortError') { + // ignore aborted errors (DOMException from AbortSignal is not instanceof Error) return; } this.logger.error(err, 'Error in EOU detection task:'); @@ -1745,7 +1745,7 @@ export class AudioRecognition { try { await this.bounceEOUTask.result; } catch (error) { - if (error instanceof Error && error.name === 'AbortError') { + if ((error as { name?: string })?.name === 'AbortError') { return; } throw error; @@ -2264,7 +2264,7 @@ export class AudioRecognition { this.logger.debug('User turn committed'); }) .catch((err: unknown) => { - if (err instanceof Error && err.name === 'AbortError') { + if ((err as { name?: string })?.name === 'AbortError') { this.logger.debug('User turn commit task cancelled'); return; } diff --git a/plugins/elevenlabs/src/stt.ts b/plugins/elevenlabs/src/stt.ts index 40c7f88fe..5eecbb6cf 100644 --- a/plugins/elevenlabs/src/stt.ts +++ b/plugins/elevenlabs/src/stt.ts @@ -393,7 +393,7 @@ export class STT extends stt.STT { if (error instanceof APIStatusError) { throw new APIConnectionError({ message: error.message }); } - if (error instanceof Error && error.name === 'AbortError') { + if ((error as { name?: string })?.name === 'AbortError') { throw new APITimeoutError({}); } throw new APIConnectionError({}); diff --git a/plugins/google/src/beta/gemini_tts.ts b/plugins/google/src/beta/gemini_tts.ts index 0d778f0c0..edd331552 100644 --- a/plugins/google/src/beta/gemini_tts.ts +++ b/plugins/google/src/beta/gemini_tts.ts @@ -267,7 +267,7 @@ export class ChunkedStream extends tts.ChunkedStream { sendLastFrame(true); } catch (error: unknown) { - if (error instanceof Error && error.name === 'AbortError') { + if ((error as { name?: string })?.name === 'AbortError') { return; } if (isAPIError(error)) throw error; diff --git a/plugins/openai/src/tts.ts b/plugins/openai/src/tts.ts index f0261e89d..d72a23c66 100644 --- a/plugins/openai/src/tts.ts +++ b/plugins/openai/src/tts.ts @@ -147,7 +147,7 @@ export class ChunkedStream extends tts.ChunkedStream { this.queue.close(); } catch (error) { - if (error instanceof Error && error.name === 'AbortError') { + if ((error as { name?: string })?.name === 'AbortError') { return; } throw error;