fix(core): skip telemetry logging for AbortError exceptions (#19477)

Co-authored-by: Yuna Seol <yunaseol@google.com>
This commit is contained in:
Yuna Seol
2026-03-02 18:14:31 -05:00
committed by GitHub
parent 25f59a0099
commit 69e15a50d1
4 changed files with 118 additions and 1 deletions
+24
View File
@@ -7,6 +7,7 @@
import { describe, it, expect } from 'vitest';
import {
isAuthenticationError,
isAbortError,
UnauthorizedError,
toFriendlyError,
BadRequestError,
@@ -48,6 +49,29 @@ describe('getErrorMessage', () => {
});
});
describe('isAbortError', () => {
it('should return true for AbortError', () => {
const error = new Error('Aborted');
error.name = 'AbortError';
expect(isAbortError(error)).toBe(true);
});
it('should return true for DOMException AbortError', () => {
const error = new DOMException('Aborted', 'AbortError');
expect(isAbortError(error)).toBe(true);
});
it('should return false for other errors', () => {
expect(isAbortError(new Error('Other error'))).toBe(false);
});
it('should return false for non-error objects', () => {
expect(isAbortError({ name: 'AbortError' })).toBe(false);
expect(isAbortError(null)).toBe(false);
expect(isAbortError('AbortError')).toBe(false);
});
});
describe('isAuthenticationError', () => {
it('should detect error with code: 401 property (MCP SDK style)', () => {
const error = { code: 401, message: 'Unauthorized' };