Skip to content

Commit 41c86e5

Browse files
committed
Fix race in proc based port finding
1 parent e268709 commit 41c86e5

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/vs/workbench/contrib/remote/browser/remoteExplorer.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,15 @@ class ProcAutomaticPortForwarding extends Disposable {
488488
) {
489489
super();
490490
this.notifier = new OnAutoForwardedAction(notificationService, remoteExplorerService, openerService, externalOpenerService, tunnelService, hostService, logService);
491-
this._register(configurationService.onDidChangeConfiguration(async (e) => {
491+
this.initialize();
492+
}
493+
494+
private async initialize() {
495+
if (!this.remoteExplorerService.tunnelModel.environmentTunnelsSet) {
496+
await new Promise<void>(resolve => this.remoteExplorerService.tunnelModel.onEnvironmentTunnelsSet(() => resolve()));
497+
}
498+
499+
this._register(this.configurationService.onDidChangeConfiguration(async (e) => {
492500
if (e.affectsConfiguration(PORT_AUTO_FORWARD_SETTING)) {
493501
await this.startStopCandidateListener();
494502
}
@@ -524,10 +532,6 @@ class ProcAutomaticPortForwarding extends Disposable {
524532
this.portsFeatures.dispose();
525533
}
526534

527-
if (!this.remoteExplorerService.tunnelModel.environmentTunnelsSet) {
528-
await new Promise<void>(resolve => this.remoteExplorerService.tunnelModel.onEnvironmentTunnelsSet(() => resolve()));
529-
}
530-
531535
// Capture list of starting candidates so we don't auto forward them later.
532536
await this.setInitialCandidates();
533537

0 commit comments

Comments
 (0)