Skip to content

The design language that makes your AI harness better at design.

JavaScript

Fix the card_heuristics navigation timeout on rust-windows at its cause (#994)

Paul Bakaus653a97705130
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index ef9ba6c4d..a68db51e4 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -204,6 +204,35 @@ jobs:
run: rustup show
- uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2
- run: cargo build --workspace --all-targets
+ # The default TEMP is on the image's C: drive. Every browser test starts
+ # Chrome on a new profile there, and with several starting at once that
+ # disk queues 30 to 40 requests deep for 20 s at a stretch: profile
+ # stores took up to 27 s to load and a page load of fourteen requests
+ # took 14 s. The runner's own temp directory is on the work drive, where
+ # the same loads stay under 3 s.
+ - name: Keep temporary files on the work drive
+ shell: pwsh
+ run: |
+ $temp = Join-Path $env:RUNNER_TEMP 'tmp'
+ New-Item -ItemType Directory -Force -Path $temp | Out-Null
+ "TEMP=$temp" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
+ "TMP=$temp" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
+ # The first Chrome start after boot reads the browser off that same C:
+ # drive and has taken 25 s to open its DevTools port, against the
+ # launcher's 30 s limit. Pay that once here, where no test is timing it.
+ # The step has taken 4 to 38 s; a start that never returns ends after
+ # three minutes and the tests run anyway.
+ - name: Start the browser once before the tests
+ shell: pwsh
+ timeout-minutes: 3
+ continue-on-error: true
+ run: |
+ $chrome = Join-Path $env:ProgramFiles 'Google\Chrome\Application\chrome.exe'
+ if (Test-Path $chrome) {
+ $profile = Join-Path $env:TEMP 'browser-warmup'
+ & $chrome --headless=new --no-sandbox --disable-gpu "--user-data-dir=$profile" --dump-dom about:blank | Out-Null
+ }
+ exit 0
- run: cargo test --workspace --no-fail-fast
launcher-windows:
diff --git a/crates/browser/src/cdp.rs b/crates/browser/src/cdp.rs
index 425a9147f..56a52ba81 100644
--- a/crates/browser/src/cdp.rs
+++ b/crates/browser/src/cdp.rs
@@ -55,7 +55,8 @@ impl From<String> for CdpError {
pub type CdpResult<T> = Result<T, CdpError>;
/// puppeteer's `ChromeLauncher.defaultArgs()` (headless, no extensions) plus
-/// the user args, in the order puppeteer emits them. `--remote-debugging-port`
+/// the user args, in the order puppeteer emits them, with one feature more
+/// switched off (see `--disable-features` below). `--remote-debugging-port`
/// and `--user-data-dir` are appended by the launcher afterwards, as
/// puppeteer's `computeLaunchArguments` does.
pub fn default_chrome_args(user_args: &[String], dangerous_no_sandbox: bool) -> Vec<String> {
@@ -86,7 +87,13 @@ pub fn default_chrome_args(user_args: &[String], dangerous_no_sandbox: bool) ->
"--no-first-run",
"--password-store=basic",
"--use-mock-keychain",
- "--disable-features=Translate,AcceptCHFrame,MediaRouter,OptimizationHints,WebUIReloadButton,ProcessPerSiteUpToMainFrameThreshold,IsolateSandboxedIframes",
+ // puppeteer's list plus `DeviceBoundSessions`. With that feature on,
+ // Chrome holds every request of a new profile until it has created
+ // and read the profile's bound-session store, which comes after the
+ // cookie store and has no protocol call to wait on. On a busy disk
+ // that took over 15 s, out of the first navigation's timeout. A
+ // throwaway profile has no bound session to honour.
+ "--disable-features=Translate,AcceptCHFrame,MediaRouter,OptimizationHints,WebUIReloadButton,ProcessPerSiteUpToMainFrameThreshold,IsolateSandboxedIframes,DeviceBoundSessions",
"--enable-features=PdfOopif",
]
.iter()
@@ -2230,6 +2237,20 @@ mod tests {
assert_eq!(with.last().unwrap(), "--no-sandbox");
assert!(with.contains(&"about:blank".to_string()));
}
+
+ /// Chrome reads only the last `--disable-features`, so the bound-session
+ /// switch has to sit in the one list the launcher passes.
+ #[test]
+ fn bound_sessions_are_off_in_the_only_feature_list() {
+ let args = default_chrome_args(&[], false);
+ let lists: Vec<&String> = args
+ .iter()
+ .filter(|a| a.starts_with("--disable-features="))
+ .collect();
+ assert_eq!(lists.len(), 1);
+ let features = lists[0].trim_start_matches("--disable-features=");
+ assert!(features.split(',').any(|f| f == "DeviceBoundSessions"));
+ }
}
/// The page-side half of [`Page::pin_clock`].