Skip to content

Commit 144f2dd

Browse files
authored
Detect incompatible local Chrome versions when running puppeteer. (#8512)
1 parent a3ef662 commit 144f2dd

File tree

3 files changed

+23
-9
lines changed

3 files changed

+23
-9
lines changed

pkg/pub_integration/lib/src/test_browser.dart

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,27 @@ class TestBrowser {
4545
final binaries = [
4646
'/usr/bin/google-chrome',
4747
];
48-
for (final binary in binaries) {
49-
if (File(binary).existsSync()) return binary;
50-
}
5148

52-
// sanity check for CI
53-
if (Platform.environment['CI'] == 'true') {
54-
throw StateError('Could not detect chrome binary while running in CI.');
49+
for (final binary in binaries) {
50+
if (File(binary).existsSync()) {
51+
// Get the local chrome's main version
52+
final pr = await Process.run(binary, ['--version'])
53+
.timeout(Duration(seconds: 5));
54+
final output = pr.stdout.toString();
55+
final mainVersion = output
56+
.split(' ')
57+
.expand((p) => p.split('.'))
58+
.map(int.tryParse)
59+
.whereType<int>()
60+
.firstOrNull;
61+
// No version string, better not running it.
62+
if (mainVersion == null) continue;
63+
// Main version is after the currently supported version, will fail.
64+
// https://github.com/xvrh/puppeteer-dart/issues/364
65+
if (mainVersion >= 132) continue;
66+
67+
return binary;
68+
}
5569
}
5670

5771
// Otherwise let puppeteer download a chrome in the local .dart_tool directory:

pkg/pub_integration/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ dependencies:
1212
http: ^1.0.0
1313
path: ^1.8.0
1414
pub_semver: ^2.0.0
15-
puppeteer: 3.12.0
15+
puppeteer: 3.16.0
1616
oauth2: ^2.0.0
1717

1818
dev_dependencies:

pubspec.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -690,10 +690,10 @@ packages:
690690
dependency: transitive
691691
description:
692692
name: puppeteer
693-
sha256: de3f921154e5d336b14cdc05b674ac3db5701a5338f3cb0042868a5146f16e67
693+
sha256: "7a990c68d33882b642214c351f66492d9a738afa4226a098ab70642357337fa2"
694694
url: "https://pub.dev"
695695
source: hosted
696-
version: "3.12.0"
696+
version: "3.16.0"
697697
retry:
698698
dependency: transitive
699699
description:

0 commit comments

Comments
 (0)