Skip to content

Commit

Permalink
fix: try to remove the temporary user data directory after the proces…
Browse files Browse the repository at this point in the history
…s has been killed (#7761)
  • Loading branch information
whimboo committed Nov 15, 2021
1 parent 7c0a7b9 commit fc94a28
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/node/BrowserRunner.ts
Expand Up @@ -180,13 +180,6 @@ export class BrowserRunner {
}

kill(): void {
// Attempt to remove temporary profile directory to avoid littering.
try {
if (this._isTempUserDataDir) {
removeFolder.sync(this._userDataDir);
}
} catch (error) {}

// If the process failed to launch (for example if the browser executable path
// is invalid), then the process does not get a pid assigned. A call to
// `proc.kill` would error, as the `pid` to-be-killed can not be found.
Expand All @@ -199,6 +192,14 @@ export class BrowserRunner {
);
}
}

// Attempt to remove temporary profile directory to avoid littering.
try {
if (this._isTempUserDataDir) {
removeFolder.sync(this._userDataDir);
}
} catch (error) {}

// Cleanup this listener last, as that makes sure the full callback runs. If we
// perform this earlier, then the previous function calls would not happen.
helper.removeEventListeners(this._listeners);
Expand Down

0 comments on commit fc94a28

Please sign in to comment.