Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(browser-runner): reject promise on error #7338

Merged
merged 4 commits into from Jul 30, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/api.md
Expand Up @@ -882,6 +882,8 @@ a single instance of [BrowserContext].

Closes Chromium and all of its pages (if any were opened). The [Browser] object itself is considered to be disposed and cannot be used anymore.

During the process of closing the browser, it will attempt to delete the temp folder created exclusively for this browser instance. If this fails (either because a file in the temp folder is locked by another process or because of insufficient permissions) it will log the error in the console and throw back the exception. This implies that: a) the folder and/or its content will not be fully deleted; and b) the connection with the browser will not be properly disposed (see [browser.disconnect()](#browserdisconnect)).
mathiasbynens marked this conversation as resolved.
Show resolved Hide resolved

#### browser.createIncognitoBrowserContext()

- returns: <[Promise]<[BrowserContext]>>
Expand Down
7 changes: 5 additions & 2 deletions src/node/BrowserRunner.ts
Expand Up @@ -91,14 +91,17 @@ export class BrowserRunner {
this.proc.stdout.pipe(process.stdout);
}
this._closed = false;
this._processClosing = new Promise((fulfill) => {
this._processClosing = new Promise((fulfill, reject) => {
this.proc.once('exit', () => {
this._closed = true;
// Cleanup as processes exit.
if (this._tempDirectory) {
removeFolderAsync(this._tempDirectory)
.then(() => fulfill())
.catch((error) => console.error(error));
.catch((error) => {
console.error(error);
reject(error);
});
} else {
fulfill();
}
Expand Down