Skip to content

Fix Chrome DevToolsActivePort crash retry for Selenium 4.0.0-alpha05#1563

Merged
lewing merged 1 commit intomainfrom
fix/chrome-devtoolsactiveport-retry
Mar 15, 2026
Merged

Fix Chrome DevToolsActivePort crash retry for Selenium 4.0.0-alpha05#1563
lewing merged 1 commit intomainfrom
fix/chrome-devtoolsactiveport-retry

Conversation

@lewing
Copy link
Copy Markdown
Member

@lewing lewing commented Mar 14, 2026

Problem

Fixes dotnet/runtime#124438 — intermittent DevToolsActivePort file doesn't exist failures in WasmTestOnChrome Helix work items.

Chrome intermittently crashes on startup in Windows containers, producing:

System.InvalidOperationException: session not created: Chrome failed to start: crashed.
  (session not created: DevToolsActivePort file doesn't exist)

The existing retry logic in GetChromiumDriver (3 attempts) never fires for this error because:

  1. The catch clause only matches TargetInvocationException with inner WebDriverException
  2. Selenium 4.0.0-alpha05 throws InvalidOperationException (not WebDriverException) for "session not created" errors
  3. The error snippet list doesn't include DevToolsActivePort

Evidence

From build 1335359, Helix job 8130ae19:

  • Server 2022 queue: 203/203 passed ✅
  • Server 2025 queue: 202/203 passed, 1 failed with DevToolsActivePort ❌
  • Pattern: 1/203 work items fail intermittently, different test names each time
  • Over 100+ occurrences tracked in the issue

Fix

  1. Broaden catch clause to also match InvalidOperationException inner exceptions (not just WebDriverException)
  2. Add error snippet DevToolsActivePort file doesn't exist to the retryable patterns
  3. Improve container detection for --no-sandbox: also check DOTNET_RUNNING_IN_CONTAINER env var (Linux Docker detection via /.dockerenv doesn't work on Windows containers)

The retry logic in GetChromiumDriver only catches TargetInvocationException
when the inner exception is WebDriverException. However, Selenium
4.0.0-alpha05 throws InvalidOperationException (not WebDriverException)
for 'session not created: Chrome failed to start: crashed' errors that
include 'DevToolsActivePort file doesn't exist'.

This means the retry never fires for this common transient failure,
causing intermittent test failures across CI (dotnet/runtime#124438).

Changes:
- Broaden catch to also match InvalidOperationException inner exceptions
- Add 'DevToolsActivePort file doesn't exist' to retryable error snippets
- Detect Windows containers via DOTNET_RUNNING_IN_CONTAINER env var
  for --no-sandbox (/.dockerenv only exists on Linux)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@lewing
Copy link
Copy Markdown
Member Author

lewing commented Mar 15, 2026

/ba-g failures are fixed by #1564

@lewing lewing merged commit 7eea15a into main Mar 15, 2026
14 of 17 checks passed
@lewing lewing deleted the fix/chrome-devtoolsactiveport-retry branch March 15, 2026 00:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

XHarness DevToolsActivePort file doesn't exist

2 participants