@@ -44,6 +44,7 @@ export interface RemoteDetails extends vscode.Disposable {
44
44
}
45
45
46
46
export class Remote {
47
+ // Used to race between the login dialog and the logging in from a different window
47
48
private loginDetectedResolver : ( ( ) => void ) | undefined ;
48
49
private loginDetectedPromise : Promise < void > = Promise . resolve ( ) ;
49
50
@@ -59,7 +60,6 @@ export class Remote {
59
60
60
61
/**
61
62
* Creates a new promise that will be resolved when login is detected in another window.
62
- * This should be called when starting a setup operation that might need login.
63
63
*/
64
64
private createLoginDetectionPromise ( ) : void {
65
65
this . loginDetectedPromise = new Promise < void > ( ( resolve ) => {
@@ -69,7 +69,6 @@ export class Remote {
69
69
70
70
/**
71
71
* Resolves the current login detection promise if one exists.
72
- * This should be called from the extension when login is detected.
73
72
*/
74
73
public resolveLoginDetected ( ) : void {
75
74
if ( this . loginDetectedResolver ) {
@@ -241,14 +240,13 @@ export class Remote {
241
240
// Migrate "session_token" file to "session", if needed.
242
241
await this . migrateSessionToken ( parts . label ) ;
243
242
244
- // Try to detect any login event that might happen after we read the current configs
245
- this . createLoginDetectionPromise ( ) ;
246
243
// Get the URL and token belonging to this host.
247
244
const { url : baseUrlRaw , token } = await this . cliManager . readConfig (
248
245
parts . label ,
249
246
) ;
250
247
251
248
const showLoginDialog = async ( message : string ) => {
249
+ this . createLoginDetectionPromise ( ) ;
252
250
const dialogPromise = this . vscodeProposed . window . showInformationMessage (
253
251
message ,
254
252
{
@@ -359,8 +357,6 @@ export class Remote {
359
357
// Next is to find the workspace from the URI scheme provided.
360
358
let workspace : Workspace ;
361
359
try {
362
- // We could've logged out in the meantime
363
- this . createLoginDetectionPromise ( ) ;
364
360
this . logger . info ( `Looking for workspace ${ workspaceName } ...` ) ;
365
361
workspace = await workspaceClient . getWorkspaceByOwnerAndName (
366
362
parts . username ,
0 commit comments