Skip to content

remote - fix some leaks #247707

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 3, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 13 additions & 14 deletions src/vs/workbench/contrib/remote/browser/remote.ts
Original file line number Diff line number Diff line change
@@ -33,7 +33,7 @@ import { IDialogService } from '../../../../platform/dialogs/common/dialogs.js';
import { ReconnectionWaitEvent, PersistentConnectionEventType } from '../../../../platform/remote/common/remoteAgentConnection.js';
import Severity from '../../../../base/common/severity.js';
import { ReloadWindowAction } from '../../../browser/actions/windowActions.js';
import { Disposable, IDisposable } from '../../../../base/common/lifecycle.js';
import { Disposable, IDisposable, MutableDisposable } from '../../../../base/common/lifecycle.js';
import { SwitchRemoteViewItem } from './explorerViewItems.js';
import { isStringArray } from '../../../../base/common/types.js';
import { HelpInformation, IRemoteExplorerService } from '../../../services/remote/common/remoteExplorerService.js';
@@ -120,7 +120,7 @@ interface IHelpItem {
handleClick(): Promise<void>;
}

class HelpModel {
class HelpModel extends Disposable {
items: IHelpItem[] | undefined;

constructor(
@@ -133,8 +133,10 @@ class HelpModel {
private workspaceContextService: IWorkspaceContextService,
private walkthroughsService: IWalkthroughsService
) {
super();

this.updateItems();
viewModel.onDidChangeHelpInformation(() => this.updateItems());
this._register(viewModel.onDidChangeHelpInformation(() => this.updateItems()));
}

private createHelpItemValue(info: HelpInformation, infoKey: Exclude<keyof HelpInformation, 'extensionDescription' | 'remoteName' | 'virtualWorkspace'>) {
@@ -491,7 +493,7 @@ class HelpPanel extends ViewPane {
}
);

const model = new HelpModel(this.viewModel, this.openerService, this.quickInputService, this.commandService, this.remoteExplorerService, this.environmentService, this.workspaceContextService, this.walkthroughsService);
const model = this._register(new HelpModel(this.viewModel, this.openerService, this.quickInputService, this.commandService, this.remoteExplorerService, this.environmentService, this.workspaceContextService, this.walkthroughsService));

this.tree.setInput(model);

@@ -545,9 +547,9 @@ class RemoteViewPaneContainer extends FilterViewPaneContainer implements IViewMo
super(VIEWLET_ID, remoteExplorerService.onDidChangeTargetType, configurationService, layoutService, telemetryService, storageService, instantiationService, themeService, contextMenuService, extensionService, contextService, viewDescriptorService, logService);
this.addConstantViewDescriptors([this.helpPanelDescriptor]);
this._register(this.remoteSwitcher = this.instantiationService.createInstance(SwitchRemoteViewItem));
this.remoteExplorerService.onDidChangeHelpInformation(extensions => {
this._register(this.remoteExplorerService.onDidChangeHelpInformation(extensions => {
this._setHelpInformation(extensions);
});
}));

this._setHelpInformation(this.remoteExplorerService.helpInformation);
const viewsRegistry = Registry.as<IViewsRegistry>(Extensions.ViewsRegistry);
@@ -804,7 +806,7 @@ export class RemoteAgentConnectionStatusListener extends Disposable implements I

let visibleProgress: VisibleProgress | null = null;
let reconnectWaitEvent: ReconnectionWaitEvent | null = null;
let disposableListener: IDisposable | null = null;
const disposableListener = this._register(new MutableDisposable());

function showProgress(location: ProgressLocation.Dialog | ProgressLocation.Notification | null, buttons: { label: string; callback: () => void }[], initialReport: string | null = null): VisibleProgress {
if (visibleProgress) {
@@ -886,13 +888,10 @@ export class RemoteAgentConnectionStatusListener extends Disposable implements I
// ReconnectionWait -> ReconnectionRunning
// ReconnectionRunning -> ConnectionGain, ReconnectionPermanentFailure

connection.onDidStateChange((e) => {
this._register(connection.onDidStateChange((e) => {
visibleProgress?.stopTimer();
disposableListener.clear();

if (disposableListener) {
disposableListener.dispose();
disposableListener = null;
}
switch (e.type) {
case PersistentConnectionEventType.ConnectionLost:
reconnectionToken = e.reconnectionToken;
@@ -961,7 +960,7 @@ export class RemoteAgentConnectionStatusListener extends Disposable implements I
visibleProgress.report(nls.localize('reconnectionRunning', "Disconnected. Attempting to reconnect..."));

// Register to listen for quick input is opened
disposableListener = quickInputService.onShow(() => {
disposableListener.value = quickInputService.onShow(() => {
// Need to move from dialog if being shown and user needs to type in a prompt
if (visibleProgress && visibleProgress.location === ProgressLocation.Dialog) {
visibleProgress = showProgress(ProgressLocation.Notification, [reloadButton], visibleProgress.lastReport);
@@ -1048,7 +1047,7 @@ export class RemoteAgentConnectionStatusListener extends Disposable implements I
hideProgress();
break;
}
});
}));
}
}
}
Original file line number Diff line number Diff line change
@@ -65,22 +65,24 @@ class RemoteAgentDiagnosticListener implements IWorkbenchContribution {
}
}

class RemoteExtensionHostEnvironmentUpdater implements IWorkbenchContribution {
class RemoteExtensionHostEnvironmentUpdater extends Disposable implements IWorkbenchContribution {
constructor(
@IRemoteAgentService remoteAgentService: IRemoteAgentService,
@IRemoteAuthorityResolverService remoteResolverService: IRemoteAuthorityResolverService,
@IExtensionService extensionService: IExtensionService
) {
super();

const connection = remoteAgentService.getConnection();
if (connection) {
connection.onDidStateChange(async e => {
this._register(connection.onDidStateChange(async e => {
if (e.type === PersistentConnectionEventType.ConnectionGain) {
const resolveResult = await remoteResolverService.resolveAuthority(connection.remoteAuthority);
if (resolveResult.options && resolveResult.options.extensionHostEnv) {
await extensionService.setRemoteEnvironment(resolveResult.options.extensionHostEnv);
}
}
});
}));
}
}
}
Original file line number Diff line number Diff line change
@@ -393,12 +393,12 @@ export class NativeExtensionService extends AbstractExtensionService implements
// monitor for breakage
const connection = this._remoteAgentService.getConnection();
if (connection) {
connection.onDidStateChange(async (e) => {
this._register(connection.onDidStateChange(async (e) => {
if (e.type === PersistentConnectionEventType.ConnectionLost) {
this._remoteAuthorityResolverService._clearResolvedAuthority(remoteAuthority);
}
});
connection.onReconnecting(() => this._resolveAuthorityAgain());
}));
this._register(connection.onReconnecting(() => this._resolveAuthorityAgain()));
}

// fetch the remote environment
Loading
Oops, something went wrong.