Skip to content

Commit

Permalink
Close connection when closing targets
Browse files Browse the repository at this point in the history
  • Loading branch information
D committed Jun 10, 2020
1 parent 912ebe3 commit 5e76473
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ The following options can be configured:

<details><h4>browserLaunchLocation</h4><p>Forces the browser to be launched in one location. In a remote workspace (through ssh or WSL, for example) this can be used to open the browser on the remote machine rather than locally.</p>
<h5>Default value:</h4><pre><code>"workspace"</pre></code><h4>cleanUp</h4><p>What clean-up to do after the debugging session finishes. Close only the tab being debug, vs. close the whole browser.</p>
<h5>Default value:</h4><pre><code>null</pre></code><h4>cwd</h4><p>Optional working directory for the runtime executable.</p>
<h5>Default value:</h4><pre><code>"onlyTab"</pre></code><h4>cwd</h4><p>Optional working directory for the runtime executable.</p>
<h5>Default value:</h4><pre><code>null</pre></code><h4>disableNetworkCache</h4><p>Controls whether to skip the network cache for each request</p>
<h5>Default value:</h4><pre><code>true</pre></code><h4>env</h4><p>Optional dictionary of environment key/value pairs for the browser.</p>
<h5>Default value:</h4><pre><code>{}</pre></code><h4>file</h4><p>A local html file to open in the browser</p>
Expand Down Expand Up @@ -359,7 +359,7 @@ The following options can be configured:
<details><h4>address</h4><p>When debugging webviews, the IP address or hostname the webview is listening on. Will be automatically discovered if not set.</p>
<h5>Default value:</h4><pre><code>"localhost"</pre></code><h4>browserLaunchLocation</h4><p>Forces the browser to be launched in one location. In a remote workspace (through ssh or WSL, for example) this can be used to open the browser on the remote machine rather than locally.</p>
<h5>Default value:</h4><pre><code>"workspace"</pre></code><h4>cleanUp</h4><p>What clean-up to do after the debugging session finishes. Close only the tab being debug, vs. close the whole browser.</p>
<h5>Default value:</h4><pre><code>null</pre></code><h4>cwd</h4><p>Optional working directory for the runtime executable.</p>
<h5>Default value:</h4><pre><code>"onlyTab"</pre></code><h4>cwd</h4><p>Optional working directory for the runtime executable.</p>
<h5>Default value:</h4><pre><code>null</pre></code><h4>disableNetworkCache</h4><p>Controls whether to skip the network cache for each request</p>
<h5>Default value:</h4><pre><code>true</pre></code><h4>env</h4><p>Optional dictionary of environment key/value pairs for the browser.</p>
<h5>Default value:</h4><pre><code>{}</pre></code><h4>file</h4><p>A local html file to open in the browser</p>
Expand Down
2 changes: 2 additions & 0 deletions src/targets/browser/browserTargets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ export class BrowserTargetManager implements IDisposable {
} else {
for (const targetId of this._targets.keys()) {
await this._browser.Target.closeTarget({ targetId });
this._connection.close();
}
}

Expand Down Expand Up @@ -351,6 +352,7 @@ export class BrowserTargetManager implements IDisposable {
await this._browser.Browser.close({});
} else {
await this._browser.Target.closeTarget({ targetId });
this._connection.close();
}
} catch {
// ignored -- any network error when we want to detach anyway is fine
Expand Down
2 changes: 2 additions & 0 deletions src/targets/browser/launcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ export async function launch(
if (options.cleanUp === 'wholeBrowser') {
await cdp.rootSession().Browser.close({});
browserProcess.kill();
} else {
cdp.close();
}
};
return { cdp: cdp, process: browserProcess };
Expand Down

0 comments on commit 5e76473

Please sign in to comment.