Skip to content

Commit

Permalink
Detect incompatible local Chrome versions when running puppeteer. (#8512
Browse files Browse the repository at this point in the history
)
  • Loading branch information
isoos authored Jan 31, 2025
1 parent a3ef662 commit 144f2dd
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
26 changes: 20 additions & 6 deletions pkg/pub_integration/lib/src/test_browser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,27 @@ class TestBrowser {
final binaries = [
'/usr/bin/google-chrome',
];
for (final binary in binaries) {
if (File(binary).existsSync()) return binary;
}

// sanity check for CI
if (Platform.environment['CI'] == 'true') {
throw StateError('Could not detect chrome binary while running in CI.');
for (final binary in binaries) {
if (File(binary).existsSync()) {
// Get the local chrome's main version
final pr = await Process.run(binary, ['--version'])
.timeout(Duration(seconds: 5));
final output = pr.stdout.toString();
final mainVersion = output
.split(' ')
.expand((p) => p.split('.'))
.map(int.tryParse)
.whereType<int>()
.firstOrNull;
// No version string, better not running it.
if (mainVersion == null) continue;
// Main version is after the currently supported version, will fail.
// https://github.com/xvrh/puppeteer-dart/issues/364
if (mainVersion >= 132) continue;

return binary;
}
}

// Otherwise let puppeteer download a chrome in the local .dart_tool directory:
Expand Down
2 changes: 1 addition & 1 deletion pkg/pub_integration/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ dependencies:
http: ^1.0.0
path: ^1.8.0
pub_semver: ^2.0.0
puppeteer: 3.12.0
puppeteer: 3.16.0
oauth2: ^2.0.0

dev_dependencies:
Expand Down
4 changes: 2 additions & 2 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -690,10 +690,10 @@ packages:
dependency: transitive
description:
name: puppeteer
sha256: de3f921154e5d336b14cdc05b674ac3db5701a5338f3cb0042868a5146f16e67
sha256: "7a990c68d33882b642214c351f66492d9a738afa4226a098ab70642357337fa2"
url: "https://pub.dev"
source: hosted
version: "3.12.0"
version: "3.16.0"
retry:
dependency: transitive
description:
Expand Down

0 comments on commit 144f2dd

Please sign in to comment.