mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
Do exponential backoff for all exceptions in VMService::defaultOpenChannel. (#16785)
We were trying to only catch WebSocketException, but in fact SocketException can be thrown as well.
This commit is contained in:
parent
060a1adec1
commit
12bbaba9ae
@ -53,7 +53,7 @@ Future<StreamChannel<String>> _defaultOpenChannel(Uri uri) async {
|
|||||||
attempts += 1;
|
attempts += 1;
|
||||||
try {
|
try {
|
||||||
socket = await io.WebSocket.connect(uri.toString());
|
socket = await io.WebSocket.connect(uri.toString());
|
||||||
} on io.WebSocketException catch(e) {
|
} catch (e) {
|
||||||
printTrace('Exception attempting to connect to observatory: $e');
|
printTrace('Exception attempting to connect to observatory: $e');
|
||||||
printTrace('This was attempt #$attempts. Will retry in $delay.');
|
printTrace('This was attempt #$attempts. Will retry in $delay.');
|
||||||
await new Future<Null>.delayed(delay);
|
await new Future<Null>.delayed(delay);
|
||||||
|
@ -4,17 +4,19 @@
|
|||||||
|
|
||||||
import 'package:test/test.dart';
|
import 'package:test/test.dart';
|
||||||
|
|
||||||
import 'package:flutter_tools/src/base/io.dart';
|
|
||||||
import 'package:flutter_tools/src/base/port_scanner.dart';
|
import 'package:flutter_tools/src/base/port_scanner.dart';
|
||||||
import 'package:flutter_tools/src/vmservice.dart';
|
import 'package:flutter_tools/src/vmservice.dart';
|
||||||
|
|
||||||
|
import 'src/common.dart';
|
||||||
|
import 'src/context.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
group('VMService', () {
|
group('VMService', () {
|
||||||
test('fails connection eagerly in the connect() method', () async {
|
testUsingContext('fails connection eagerly in the connect() method', () async {
|
||||||
final int port = await const HostPortScanner().findAvailablePort();
|
final int port = await const HostPortScanner().findAvailablePort();
|
||||||
expect(
|
expect(
|
||||||
VMService.connect(Uri.parse('http://localhost:$port')),
|
VMService.connect(Uri.parse('http://localhost:$port')),
|
||||||
throwsA(const isInstanceOf<SocketException>()),
|
throwsToolExit(),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user