@@ -59,6 +59,7 @@ export class Remote {
59
59
private readonly pathResolver : PathResolver ;
60
60
private readonly cliManager : CliManager ;
61
61
62
+ // Used to race between the login dialog and the logging in from a different window
62
63
private loginDetectedResolver : ( ( ) => void ) | undefined ;
63
64
private loginDetectedPromise : Promise < void > = Promise . resolve ( ) ;
64
65
@@ -75,7 +76,6 @@ export class Remote {
75
76
76
77
/**
77
78
* Creates a new promise that will be resolved when login is detected in another window.
78
- * This should be called when starting a setup operation that might need login.
79
79
*/
80
80
private createLoginDetectionPromise ( ) : void {
81
81
this . loginDetectedPromise = new Promise < void > ( ( resolve ) => {
@@ -85,7 +85,6 @@ export class Remote {
85
85
86
86
/**
87
87
* Resolves the current login detection promise if one exists.
88
- * This should be called from the extension when login is detected.
89
88
*/
90
89
public resolveLoginDetected ( ) : void {
91
90
if ( this . loginDetectedResolver ) {
@@ -257,14 +256,13 @@ export class Remote {
257
256
// Migrate "session_token" file to "session", if needed.
258
257
await this . migrateSessionToken ( parts . label ) ;
259
258
260
- // Try to detect any login event that might happen after we read the current configs
261
- this . createLoginDetectionPromise ( ) ;
262
259
// Get the URL and token belonging to this host.
263
260
const { url : baseUrlRaw , token } = await this . cliManager . readConfig (
264
261
parts . label ,
265
262
) ;
266
263
267
264
const showLoginDialog = async ( message : string ) => {
265
+ this . createLoginDetectionPromise ( ) ;
268
266
const dialogPromise = this . vscodeProposed . window . showInformationMessage (
269
267
message ,
270
268
{
@@ -370,8 +368,6 @@ export class Remote {
370
368
// Next is to find the workspace from the URI scheme provided.
371
369
let workspace : Workspace ;
372
370
try {
373
- // We could've logged out in the meantime
374
- this . createLoginDetectionPromise ( ) ;
375
371
this . logger . info ( `Looking for workspace ${ workspaceName } ...` ) ;
376
372
workspace = await workspaceClient . getWorkspaceByOwnerAndName (
377
373
parts . username ,
0 commit comments