Skip to content

Commit 57bc194

Browse files
committed
Do emit traceback when closing the auth prepare window.
1 parent 8c65bd4 commit 57bc194

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

src/sharedOperations.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
hasGraphicalEnvironment,
2020
} from './playwrightUtils.js';
2121
import type { ServiceRegistry } from './serviceRegistry.js';
22+
import { isBrowserClosedError, LoginCancelledError } from './services/core/base.js';
2223
import { RegisteredService } from './services/core/registered.js';
2324
import type { Service } from './services/index.js';
2425

@@ -222,7 +223,19 @@ export async function authBrowserPrepare(
222223

223224
const launchOptions = getBrowserLaunchOptions(config);
224225

225-
const apiCredentials = await session.prepare(encryptedStorage, launchOptions);
226+
let apiCredentials;
227+
try {
228+
apiCredentials = await session.prepare(encryptedStorage, launchOptions);
229+
} catch (error: unknown) {
230+
// Closing the browser window during preparation should be reported to
231+
// the user as a clean cancellation rather than a stack trace. Doing
232+
// this here means every service's prepare() gets the same treatment
233+
// without having to repeat the wrapping in each implementation.
234+
if (error instanceof Error && isBrowserClosedError(error)) {
235+
throw new LoginCancelledError();
236+
}
237+
throw error;
238+
}
226239
apiCredentialStore.save(service.name, apiCredentials);
227240
return { alreadyPrepared: false };
228241
}

0 commit comments

Comments
 (0)