fix: memory leak in LoggerChannel (#315875)

This commit is contained in:
Simon Siefke
2026-05-21 07:03:50 +02:00
committed by GitHub
parent e4cb08595b
commit 1fc96f74c5
2 changed files with 11 additions and 3 deletions
+1 -1
View File
@@ -1373,7 +1373,7 @@ export class CodeApplication extends Disposable {
mainProcessElectronServer.registerChannel(McpGatewayChannelName, mcpGatewayChannel);
// Logger
const loggerChannel = new LoggerChannel(accessor.get(ILoggerMainService),);
const loggerChannel = this._register(new LoggerChannel(accessor.get(ILoggerMainService)));
mainProcessElectronServer.registerChannel('logger', loggerChannel);
sharedProcessClient.then(client => client.registerChannel('logger', loggerChannel));
+10 -2
View File
@@ -4,17 +4,25 @@
*--------------------------------------------------------------------------------------------*/
import { Event } from '../../../base/common/event.js';
import { Disposable } from '../../../base/common/lifecycle.js';
import { ResourceMap } from '../../../base/common/map.js';
import { URI } from '../../../base/common/uri.js';
import { IServerChannel } from '../../../base/parts/ipc/common/ipc.js';
import { ILogger, ILoggerOptions, isLogLevel, log, LogLevel } from '../common/log.js';
import { ILoggerMainService } from './loggerService.js';
export class LoggerChannel implements IServerChannel {
export class LoggerChannel extends Disposable implements IServerChannel {
private readonly loggers = new ResourceMap<ILogger>();
constructor(private readonly loggerService: ILoggerMainService) { }
constructor(private readonly loggerService: ILoggerMainService) {
super();
this._register(this.loggerService.onDidChangeLoggers(({ removed }) => {
for (const loggerResource of removed) {
this.loggers.delete(loggerResource.resource);
}
}));
}
listen(_: unknown, event: string, windowId?: number): Event<any> {
switch (event) {