mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
Add additional logging when devtools cannot launch (#81554)
This commit is contained in:
parent
7912cbea38
commit
1edaec6c2c
@ -67,9 +67,16 @@ class DevtoolsServerLauncher extends DevtoolsLauncher {
|
|||||||
final io.HttpClientResponse response = await request.close();
|
final io.HttpClientResponse response = await request.close();
|
||||||
await response.drain<void>();
|
await response.drain<void>();
|
||||||
if (response.statusCode != io.HttpStatus.ok) {
|
if (response.statusCode != io.HttpStatus.ok) {
|
||||||
|
_logger.printTrace(
|
||||||
|
'Skipping devtools launch because pub.dev responded with HTTP '
|
||||||
|
'status code ${response.statusCode} instead of ${io.HttpStatus.ok}.',
|
||||||
|
);
|
||||||
offline = true;
|
offline = true;
|
||||||
}
|
}
|
||||||
} on Exception {
|
} on Exception catch (e) {
|
||||||
|
_logger.printTrace(
|
||||||
|
'Skipping devtools launch because connecting to pub.dev failed with $e',
|
||||||
|
);
|
||||||
offline = true;
|
offline = true;
|
||||||
} on ArgumentError {
|
} on ArgumentError {
|
||||||
if (!useOverrideUrl) {
|
if (!useOverrideUrl) {
|
||||||
|
@ -363,4 +363,48 @@ void main() {
|
|||||||
|
|
||||||
expect(logger.errorText, contains('Failed to launch DevTools: ProcessException'));
|
expect(logger.errorText, contains('Failed to launch DevTools: ProcessException'));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
testWithoutContext('DevtoolsLauncher prints trace if connecting to pub.dev throws', () async {
|
||||||
|
final DevtoolsLauncher launcher = DevtoolsServerLauncher(
|
||||||
|
pubExecutable: 'pub',
|
||||||
|
logger: logger,
|
||||||
|
platform: platform,
|
||||||
|
persistentToolState: persistentToolState,
|
||||||
|
httpClient: FakeHttpClient.list(<FakeRequest>[
|
||||||
|
FakeRequest(
|
||||||
|
Uri.https('pub.dev', ''),
|
||||||
|
method: HttpMethod.head,
|
||||||
|
responseError: Exception('Connection failed.'),
|
||||||
|
),
|
||||||
|
]),
|
||||||
|
processManager: FakeProcessManager.empty(),
|
||||||
|
);
|
||||||
|
|
||||||
|
await launcher.launch(Uri.parse('http://127.0.0.1:1234/abcdefg'));
|
||||||
|
|
||||||
|
expect(logger.traceText, contains('Skipping devtools launch because connecting to pub.dev failed with Exception: Connection failed.'));
|
||||||
|
});
|
||||||
|
|
||||||
|
testWithoutContext('DevtoolsLauncher prints trace if connecting to pub.dev returns non-OK status code', () async {
|
||||||
|
final DevtoolsLauncher launcher = DevtoolsServerLauncher(
|
||||||
|
pubExecutable: 'pub',
|
||||||
|
logger: logger,
|
||||||
|
platform: platform,
|
||||||
|
persistentToolState: persistentToolState,
|
||||||
|
httpClient: FakeHttpClient.list(<FakeRequest>[
|
||||||
|
FakeRequest(
|
||||||
|
Uri.https('pub.dev', ''),
|
||||||
|
method: HttpMethod.head,
|
||||||
|
response: const FakeResponse(
|
||||||
|
statusCode: HttpStatus.forbidden
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]),
|
||||||
|
processManager: FakeProcessManager.empty(),
|
||||||
|
);
|
||||||
|
|
||||||
|
await launcher.launch(Uri.parse('http://127.0.0.1:1234/abcdefg'));
|
||||||
|
|
||||||
|
expect(logger.traceText, contains('Skipping devtools launch because pub.dev responded with HTTP status code 403 instead of 200.'));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user