Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add some retry around browser launching #1676

Merged
merged 5 commits into from
Mar 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pkgs/test/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
## 1.20.2-dev
## 1.20.2

* Drop `dart2js-path` command line argument.
* Allow loading tests under a path with the directory named `packages`.
* Add retry for launching browsers. Reduce timeout back to 30 seconds.

## 1.20.1

Expand Down
23 changes: 18 additions & 5 deletions pkgs/test/lib/src/runner/browser/browser_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,21 @@ class BrowserManager {
/// Returns the browser manager, or throws an [ApplicationException] if a
/// connection fails to be established.
static Future<BrowserManager> start(
Runtime runtime,
Uri url,
Future<WebSocketChannel> future,
ExecutableSettings settings,
Configuration configuration) =>
_start(runtime, url, future, settings, configuration, 1);

static const _maxRetries = 3;
static Future<BrowserManager> _start(
Runtime runtime,
Uri url,
Future<WebSocketChannel> future,
ExecutableSettings settings,
Configuration configuration) {
Configuration configuration,
int attempt) {
var browser = _newBrowser(url, runtime, settings, configuration);

var completer = Completer<BrowserManager>();
Expand All @@ -127,11 +137,14 @@ class BrowserManager {
completer.completeError(error, stackTrace);
});

return completer.future.timeout(Duration(seconds: 45), onTimeout: () {
return completer.future.timeout(Duration(seconds: 30), onTimeout: () {
browser.close();
throw ApplicationException(
'Timed out waiting for ${runtime.name} to connect.\n'
'Browser output: ${utf8.decode(browser.output)}');
if (attempt >= _maxRetries) {
throw ApplicationException(
'Timed out waiting for ${runtime.name} to connect.\n'
'Browser output: ${utf8.decode(browser.output)}');
}
return _start(runtime, url, future, settings, configuration, ++attempt);
});
}

Expand Down
2 changes: 1 addition & 1 deletion pkgs/test/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: test
version: 1.20.2-dev
version: 1.20.2
description: >-
A full featured library for writing and running Dart tests across platforms.
repository: https://github.com/dart-lang/test/blob/master/pkgs/test
Expand Down