-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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: wait for the process to close when closing the browser #1629
fix: wait for the process to close when closing the browser #1629
Conversation
src/firefox/ffBrowser.ts
Outdated
await Promise.all(this.contexts().map(context => context.close())); | ||
helper.removeEventListeners(this._eventListeners); | ||
const disconnected = new Promise(f => this.once(Events.Browser.Disconnected, f)); | ||
this._connection.close(); | ||
await disconnected; | ||
} | ||
|
||
async close() { | ||
if (this._closeOverride) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Pavel suggested you could use this.__server__.close()
if server is set instead of passing the callback. *Broser.close() implementation would be a bit more obvious then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can make it this._server to make it more legit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done as _ownedServer
@@ -135,7 +135,7 @@ export async function launchProcess(options: LaunchProcessOptions): Promise<Laun | |||
} | |||
gracefullyClosing = true; | |||
debugBrowser(`<gracefully close start>`); | |||
options.attemptToGracefullyClose().catch(() => killProcess()); | |||
await options.attemptToGracefullyClose().catch(() => killProcess()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if killProcess throws, the error will appear in the right place, among other subtle changes. I always prefer to await promises.
0af34b9
to
4f07bc9
Compare
4f07bc9
to
a24ead1
Compare
I had a test, but it was chromium only (reading the cookies file). I'll work on a better one.