Skip to content

Commit

Permalink
Fix timing issue where port detection can fail to start
Browse files Browse the repository at this point in the history
  • Loading branch information
alexr00 committed Jun 15, 2021
1 parent 9d4274b commit fe8bb48
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/vs/platform/remote/common/tunnel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export interface ITunnelService {
readonly onTunnelClosed: Event<{ host: string, port: number; }>;
readonly canElevate: boolean;
readonly hasTunnelProvider: boolean;
readonly onAddedTunnelProvider: Event<void>;

canTunnel(uri: URI): boolean;
openTunnel(addressProvider: IAddressProvider | undefined, remoteHost: string | undefined, remotePort: number, localPort?: number, elevateIfNeeded?: boolean, isPublic?: boolean): Promise<RemoteTunnel | undefined> | undefined;
Expand Down Expand Up @@ -133,6 +134,8 @@ export abstract class AbstractTunnelService implements ITunnelService {
public onTunnelOpened: Event<RemoteTunnel> = this._onTunnelOpened.event;
private _onTunnelClosed: Emitter<{ host: string, port: number; }> = new Emitter();
public onTunnelClosed: Event<{ host: string, port: number; }> = this._onTunnelClosed.event;
private _onAddedTunnelProvider: Emitter<void> = new Emitter();
public onAddedTunnelProvider: Event<void> = this._onAddedTunnelProvider.event;
protected readonly _tunnels = new Map</*host*/ string, Map</* port */ number, { refcount: number, readonly value: Promise<RemoteTunnel | undefined>; }>>();
protected _tunnelProvider: ITunnelProvider | undefined;
protected _canElevate: boolean = false;
Expand All @@ -152,12 +155,14 @@ export abstract class AbstractTunnelService implements ITunnelService {
// clear features
this._canElevate = false;
this._canMakePublic = false;
this._onAddedTunnelProvider.fire();
return {
dispose: () => { }
};
}
this._canElevate = features.elevation;
this._canMakePublic = features.public;
this._onAddedTunnelProvider.fire();
return {
dispose: () => {
this._tunnelProvider = undefined;
Expand Down
3 changes: 3 additions & 0 deletions src/vs/workbench/api/browser/mainThreadTunnelService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ export class MainThreadTunnelService extends Disposable implements MainThreadTun
return this._proxy.$registerCandidateFinder(this.processFindingEnabled());
}
}));
this._register(this.tunnelService.onAddedTunnelProvider(() => {
return this._proxy.$registerCandidateFinder(this.processFindingEnabled());
}));
}

private _alreadyRegistered: boolean = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ class SimpleTunnelService implements ITunnelService {
canMakePublic = false;
onTunnelOpened = Event.None;
onTunnelClosed = Event.None;
onAddedTunnelProvider = Event.None;
hasTunnelProvider = false;

canTunnel(uri: URI): boolean { return false; }
Expand Down

0 comments on commit fe8bb48

Please sign in to comment.