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: wait for the process to close when closing the browser #1629

Merged
merged 1 commit into from
Apr 2, 2020

Conversation

JoelEinbinder
Copy link
Contributor

I had a test, but it was chromium only (reading the cookies file). I'll work on a better one.

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)
Copy link
Member

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.

Copy link
Member

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done as _ownedServer

src/server/pipeTransport.ts Outdated Show resolved Hide resolved
@@ -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());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it necessary?

Copy link
Contributor Author

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.

@JoelEinbinder JoelEinbinder merged commit 3d6d9db into microsoft:master Apr 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants