fix(core): Resolve AbortSignal MaxListenersExceededWarning (#5950) (#16735)

This commit is contained in:
Spencer
2026-01-22 20:16:00 +00:00
committed by GitHub
parent e2ddaedab4
commit 5d68d8cda5
5 changed files with 41 additions and 20 deletions
+7 -4
View File
@@ -1043,10 +1043,13 @@ describe('mcp-client', () => {
if (options?.signal?.aborted) {
return reject(new Error('Operation aborted'));
}
options?.signal?.addEventListener('abort', () => {
reject(new Error('Operation aborted'));
});
// Intentionally do not resolve immediately to simulate lag
options?.signal?.addEventListener(
'abort',
() => {
reject(new Error('Operation aborted'));
},
{ once: true },
);
}),
),
listPrompts: vi.fn().mockResolvedValue({ prompts: [] }),
+1 -1
View File
@@ -242,7 +242,7 @@ export abstract class BaseToolInvocation<
}
};
abortSignal.addEventListener('abort', abortHandler);
abortSignal.addEventListener('abort', abortHandler, { once: true });
timeoutId = setTimeout(() => {
cleanup();