Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion codex-vscode/src/services/oauth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,14 @@ export class OAuthService implements IOAuthService {
);
}

// The Promise.race method is used here to race two promises against each other:
// 1. OAuthService.codeExchangePromise.promise - This promise resolves when the user completes the authorization process.
// 2. A timeout promise that rejects after 60 seconds, indicating the user did not complete the login in time.
// The first promise to settle (either resolve or reject) will determine the outcome of the authenticate method.
return Promise.race([
OAuthService.codeExchangePromise.promise,
new Promise<ErrorResponse>((_, reject) =>
setTimeout(() => {
// TODO we should make this alot simpler
this.clearCodeExchangePromise();
reject({
errorType: "cancelled",
Expand All @@ -46,6 +49,7 @@ export class OAuthService implements IOAuthService {
]);
}


// postAuthorization returns a function that is called from the promiseFromEvent function when the event is fired
private postAuthorization: () => PromiseAdapter<vscode.Uri, UserInfo> =
() =>
Expand Down