address listener leak (#208989)

fixes https://github.com/microsoft/vscode/issues/207446
This commit is contained in:
Johannes Rieken 2024-03-28 10:08:25 +01:00 committed by GitHub
parent 77b02f1e24
commit 94f7c1d971
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -243,8 +243,8 @@ export class NativeLocalProcessExtensionHost implements IExtensionHost {
// Catch all output coming from the extension host process // Catch all output coming from the extension host process
type Output = { data: string; format: string[] }; type Output = { data: string; format: string[] };
const onStdout = this._handleProcessOutputStream(this._extensionHostProcess.onStdout); const onStdout = this._handleProcessOutputStream(this._extensionHostProcess.onStdout, this._toDispose);
const onStderr = this._handleProcessOutputStream(this._extensionHostProcess.onStderr); const onStderr = this._handleProcessOutputStream(this._extensionHostProcess.onStderr, this._toDispose);
const onOutput = Event.any( const onOutput = Event.any(
Event.map(onStdout.event, o => ({ data: `%c${o}`, format: [''] })), Event.map(onStdout.event, o => ({ data: `%c${o}`, format: [''] })),
Event.map(onStderr.event, o => ({ data: `%c${o}`, format: ['color: red'] })) Event.map(onStderr.event, o => ({ data: `%c${o}`, format: ['color: red'] }))
@ -258,7 +258,7 @@ export class NativeLocalProcessExtensionHost implements IExtensionHost {
}, 100); }, 100);
// Print out extension host output // Print out extension host output
onDebouncedOutput(output => { this._toDispose.add(onDebouncedOutput(output => {
const inspectorUrlMatch = output.data && output.data.match(/ws:\/\/([^\s]+:(\d+)\/[^\s]+)/); const inspectorUrlMatch = output.data && output.data.match(/ws:\/\/([^\s]+:(\d+)\/[^\s]+)/);
if (inspectorUrlMatch) { if (inspectorUrlMatch) {
if (!this._environmentService.isBuilt && !this._isExtensionDevTestFromCli) { if (!this._environmentService.isBuilt && !this._isExtensionDevTestFromCli) {
@ -275,7 +275,7 @@ export class NativeLocalProcessExtensionHost implements IExtensionHost {
console.groupEnd(); console.groupEnd();
} }
} }
}); }));
// Lifecycle // Lifecycle
@ -521,7 +521,7 @@ export class NativeLocalProcessExtensionHost implements IExtensionHost {
this._onExit.fire([code, signal]); this._onExit.fire([code, signal]);
} }
private _handleProcessOutputStream(stream: Event<string>) { private _handleProcessOutputStream(stream: Event<string>, store: DisposableStore) {
let last = ''; let last = '';
let isOmitting = false; let isOmitting = false;
const event = new Emitter<string>(); const event = new Emitter<string>();
@ -549,7 +549,7 @@ export class NativeLocalProcessExtensionHost implements IExtensionHost {
event.fire(line + '\n'); event.fire(line + '\n');
} }
} }
}); }, undefined, store);
return event; return event;
} }