未验证 提交 08bca485 编写于 作者: A Alex Ross 提交者: GitHub

Fix race that causes auto port forwarding setting to be ignored (#126481)

* Fix race in proc based port finding

* Check port auto forward setting after waiting

Fixes microsoft/vscode-remote-release#5208
上级 2650c2e5
......@@ -488,7 +488,15 @@ class ProcAutomaticPortForwarding extends Disposable {
) {
super();
this.notifier = new OnAutoForwardedAction(notificationService, remoteExplorerService, openerService, externalOpenerService, tunnelService, hostService, logService);
this._register(configurationService.onDidChangeConfiguration(async (e) => {
this.initialize();
}
private async initialize() {
if (!this.remoteExplorerService.tunnelModel.environmentTunnelsSet) {
await new Promise<void>(resolve => this.remoteExplorerService.tunnelModel.onEnvironmentTunnelsSet(() => resolve()));
}
this._register(this.configurationService.onDidChangeConfiguration(async (e) => {
if (e.affectsConfiguration(PORT_AUTO_FORWARD_SETTING)) {
await this.startStopCandidateListener();
}
......@@ -524,14 +532,13 @@ class ProcAutomaticPortForwarding extends Disposable {
this.portsFeatures.dispose();
}
if (!this.remoteExplorerService.tunnelModel.environmentTunnelsSet) {
await new Promise<void>(resolve => this.remoteExplorerService.tunnelModel.onEnvironmentTunnelsSet(() => resolve()));
}
// Capture list of starting candidates so we don't auto forward them later.
await this.setInitialCandidates();
this.candidateListener = this._register(this.remoteExplorerService.tunnelModel.onCandidatesChanged(this.handleCandidateUpdate, this));
// Need to check the setting again, since it may have changed while we waited for the initial candidates to be set.
if (this.configurationService.getValue(PORT_AUTO_FORWARD_SETTING)) {
this.candidateListener = this._register(this.remoteExplorerService.tunnelModel.onCandidatesChanged(this.handleCandidateUpdate, this));
}
}
private async setInitialCandidates() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册