mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
fix(browser-runner): reject promise on error (#7338)
This patch adds a reject callback to the _processClosing promise and executes it if it catches an error on removeFolderAsync(...). Co-authored-by: Mathias Bynens <mathias@qiwi.be>
This commit is contained in:
parent
39c1f08fd6
commit
5eb20e29a2
@ -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.
|
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, Puppeteer attempts 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) an error is logged. This implies that: a) the folder and/or its content is not fully deleted; and b) the connection with the browser is not properly disposed (see [browser.disconnect()](#browserdisconnect)).
|
||||||
|
|
||||||
#### browser.createIncognitoBrowserContext()
|
#### browser.createIncognitoBrowserContext()
|
||||||
|
|
||||||
- returns: <[Promise]<[BrowserContext]>>
|
- returns: <[Promise]<[BrowserContext]>>
|
||||||
|
@ -91,14 +91,17 @@ export class BrowserRunner {
|
|||||||
this.proc.stdout.pipe(process.stdout);
|
this.proc.stdout.pipe(process.stdout);
|
||||||
}
|
}
|
||||||
this._closed = false;
|
this._closed = false;
|
||||||
this._processClosing = new Promise((fulfill) => {
|
this._processClosing = new Promise((fulfill, reject) => {
|
||||||
this.proc.once('exit', () => {
|
this.proc.once('exit', () => {
|
||||||
this._closed = true;
|
this._closed = true;
|
||||||
// Cleanup as processes exit.
|
// Cleanup as processes exit.
|
||||||
if (this._tempDirectory) {
|
if (this._tempDirectory) {
|
||||||
removeFolderAsync(this._tempDirectory)
|
removeFolderAsync(this._tempDirectory)
|
||||||
.then(() => fulfill())
|
.then(() => fulfill())
|
||||||
.catch((error) => console.error(error));
|
.catch((error) => {
|
||||||
|
console.error(error);
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
fulfill();
|
fulfill();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user