Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
c6f77923
Unverified
Commit
c6f77923
authored
May 22, 2020
by
James D. Lin
Committed by
GitHub
May 22, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter tools] Improve messages when we fail to connect to the Observatory (#57355)
parent
852a30b0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
4 deletions
+59
-4
vmservice.dart
packages/flutter_tools/lib/src/vmservice.dart
+17
-4
vmservice_test.dart
...ages/flutter_tools/test/general.shard/vmservice_test.dart
+42
-0
No files found.
packages/flutter_tools/lib/src/vmservice.dart
View file @
c6f77923
...
...
@@ -89,13 +89,26 @@ Future<io.WebSocket> _defaultOpenChannel(String url, {
io
.
WebSocket
socket
;
Future
<
void
>
handleError
(
dynamic
e
)
async
{
globals
.
printTrace
(
'Exception attempting to connect to Observatory:
$e
'
);
globals
.
printTrace
(
'This was attempt #
$attempts
. Will retry in
$delay
.'
);
void
Function
(
String
)
printVisibleTrace
=
globals
.
printTrace
;
if
(
attempts
==
10
)
{
globals
.
printStatus
(
'This is taking longer than expected...'
);
globals
.
printStatus
(
'Connecting to the VM Service is taking longer than expected...'
);
}
else
if
(
attempts
==
20
)
{
globals
.
printStatus
(
'Still attempting to connect to the VM Service...'
);
globals
.
printStatus
(
'If you do NOT see the Flutter application running, it might have '
'crashed. The device logs (e.g. from adb or XCode) might have more '
'details.'
);
globals
.
printStatus
(
'If you do see the Flutter application running on the device, try '
're-running with --host-vmservice-port to use a specific port known to '
'be available.'
);
}
else
if
(
attempts
%
50
==
0
)
{
printVisibleTrace
=
globals
.
printStatus
;
}
printVisibleTrace
(
'Exception attempting to connect to the VM Service:
$e
'
);
printVisibleTrace
(
'This was attempt #
$attempts
. Will retry in
$delay
.'
);
// Delay next attempt.
await
Future
<
void
>.
delayed
(
delay
);
...
...
packages/flutter_tools/test/general.shard/vmservice_test.dart
View file @
c6f77923
...
...
@@ -5,6 +5,7 @@
import
'dart:async'
;
import
'package:flutter_tools/src/base/common.dart'
;
import
'package:flutter_tools/src/base/io.dart'
as
io
;
import
'package:flutter_tools/src/convert.dart'
;
import
'package:vm_service/vm_service.dart'
as
vm_service
;
import
'package:mockito/mockito.dart'
;
...
...
@@ -12,6 +13,7 @@ import 'package:flutter_tools/src/base/logger.dart';
import
'package:flutter_tools/src/device.dart'
;
import
'package:flutter_tools/src/version.dart'
;
import
'package:flutter_tools/src/vmservice.dart'
;
import
'package:quiver/testing/async.dart'
;
import
'../src/common.dart'
;
import
'../src/context.dart'
;
...
...
@@ -161,6 +163,38 @@ void main() {
FlutterVersion:
()
=>
MockFlutterVersion
(),
});
testUsingContext
(
'VMService prints messages for connection failures'
,
()
{
FakeAsync
().
run
((
FakeAsync
time
)
{
final
Uri
uri
=
Uri
.
parse
(
'ws://127.0.0.1:12345/QqL7EFEDNG0=/ws'
);
unawaited
(
connectToVmService
(
uri
));
time
.
elapse
(
const
Duration
(
seconds:
5
));
expect
(
testLogger
.
statusText
,
isEmpty
);
time
.
elapse
(
const
Duration
(
minutes:
2
));
final
String
statusText
=
testLogger
.
statusText
;
expect
(
statusText
,
containsIgnoringWhitespace
(
'Connecting to the VM Service is taking longer than expected...'
),
);
expect
(
statusText
,
containsIgnoringWhitespace
(
'try re-running with --host-vmservice-port'
),
);
expect
(
statusText
,
containsIgnoringWhitespace
(
'Exception attempting to connect to the VM Service:'
),
);
expect
(
statusText
,
containsIgnoringWhitespace
(
'This was attempt #50. Will retry'
),
);
});
},
overrides:
<
Type
,
Generator
>{
WebSocketConnector:
()
=>
failingWebSocketConnector
,
});
testWithoutContext
(
'setAssetDirectory forwards arguments correctly'
,
()
async
{
final
Completer
<
String
>
completer
=
Completer
<
String
>();
final
vm_service
.
VmService
vmService
=
vm_service
.
VmService
(
...
...
@@ -323,3 +357,11 @@ class MockFlutterVersion extends Mock implements FlutterVersion {
@override
Map
<
String
,
Object
>
toJson
()
=>
const
<
String
,
Object
>{
'Mock'
:
'Version'
};
}
/// A [WebSocketConnector] that always throws an [io.SocketException].
Future
<
io
.
WebSocket
>
failingWebSocketConnector
(
String
url
,
{
io
.
CompressionOptions
compression
,
})
{
throw
const
io
.
SocketException
(
'Failed WebSocket connection'
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment