fix(core): dispose Scheduler to prevent McpProgress listener leak (#24870)

This commit is contained in:
Anjaligarhwal
2026-04-08 08:35:53 +05:30
committed by GitHub
parent 47c5d25d93
commit b9f1d832c8
6 changed files with 65 additions and 3 deletions

View File

@@ -184,6 +184,7 @@ export async function runNonInteractive({
};
let errorToHandle: unknown | undefined;
let scheduler: Scheduler | undefined;
let abortSession = () => {};
try {
consolePatcher.patch();
@@ -215,7 +216,7 @@ export async function runNonInteractive({
});
const geminiClient = config.getGeminiClient();
const scheduler = new Scheduler({
scheduler = new Scheduler({
context: config,
messageBus: config.getMessageBus(),
getPreferredEditor: () => undefined,
@@ -612,6 +613,7 @@ export async function runNonInteractive({
cleanupStdinCancellation();
abortController.signal.removeEventListener('abort', abortSession);
scheduler?.dispose();
consolePatcher.cleanup();
coreEvents.off(CoreEvent.UserFeedback, handleUserFeedback);
}