Unverified Commit 1edaec6c authored by Michael Goderbauer's avatar Michael Goderbauer Committed by GitHub

Add additional logging when devtools cannot launch (#81554)

parent 7912cbea
......@@ -67,9 +67,16 @@ class DevtoolsServerLauncher extends DevtoolsLauncher {
final io.HttpClientResponse response = await request.close();
await response.drain<void>();
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;
}
} on Exception {
} on Exception catch (e) {
_logger.printTrace(
'Skipping devtools launch because connecting to pub.dev failed with $e',
);
offline = true;
} on ArgumentError {
if (!useOverrideUrl) {
......
......@@ -363,4 +363,48 @@ void main() {
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.'));
});
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment