forked from firka/flutter
Handle a SocketException thrown when sending the browser close command to Chrome (#151197)
https://github.com/flutter/flutter/pull/150645 tries to shut down Chrome by sending a browser close command through a debug protocol. The webkit_inspection_protocol library used to send the command may throw a SocketException if Chrome has already been shut down.
This commit is contained in:
@@ -507,8 +507,14 @@ class Chromium {
|
||||
// Send a command to shut down the browser cleanly.
|
||||
Duration sigtermDelay = Duration.zero;
|
||||
if (_hasValidChromeConnection) {
|
||||
final ChromeTab? tab = await chromeConnection.getTab(
|
||||
(_) => true, retryFor: const Duration(seconds: 1));
|
||||
ChromeTab? tab;
|
||||
try {
|
||||
tab = await chromeConnection.getTab(
|
||||
(_) => true, retryFor: const Duration(seconds: 1));
|
||||
} on SocketException {
|
||||
// Chrome is not responding to the debug protocol and probably has
|
||||
// already been closed.
|
||||
}
|
||||
if (tab != null) {
|
||||
final WipConnection wipConnection = await tab.connect();
|
||||
await wipConnection.sendCommand('Browser.close');
|
||||
|
||||
Reference in New Issue
Block a user