Skip to content

Start a browser session again when the browser or its driver did not start - #39

Draft
jwrosewell wants to merge 2 commits into
rcfrom
fix/retry-browser-start
Draft

jwrosewell wants to merge 2 commits into
rcfrom
fix/retry-browser-start

Conversation

@jwrosewell

@jwrosewell jwrosewell commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Problem

A Chrome driver that starts the browser and then cannot reach it answers session not created from disconnected: unable to connect to renderer (SessionNotCreated), and Helpers/BrowserDrivers.cs made one attempt, so that answer failed the test outright. It has failed builds in three language repositories over the weekend of 14 to 16 November 2026.

Build Job Test
51degrees-node run 43560055156 attempt 1, 14 November 05:52 UTC Windows_Node_24 Example_RendersRealDetectionResult failed in 931 ms
51degrees-node run 43785288481 attempt 1, 16 November 02:09 UTC Windows_Node_24 the same test

Each failure came back from the ChromeDriver constructor in about a second, with System.InvalidOperationException and that message, so nothing in the test had run yet. 51degrees-python's own failures (run 43590775623 and run 43618020992) are a different fault in Python's own Selenium library and are not touched by this.

This is a failure that a re-run clears, which is what the rule of 13 November 2026 says not to do, so it is fixed here.

What changed

BrowserDrivers.Retried runs the call that creates a session and, when the browser or its driver did not start, runs it again up to SessionStartAttempts times, which is 3, waiting SessionRetryDelaySeconds, which is 2, between attempts. Every local Chrome, Firefox and Edge session goes through it, on both routes, being the driver the machine provides and the driver Selenium Manager fetches.

Three things it does not do.

  1. What stops the last attempt travels on exactly as it is, so the error a test reports does not change. The attempts are visible in the test's output, where each failed attempt writes a line naming the browser, the attempt and the first line of the failure.
  2. A remote session on a Selenium grid is left as it was, because the grid queues and answers its own session requests, and no failure of this kind has been measured there.
  3. The first start of Chrome and Firefox, which StartOnce makes before the first test that asks for the browser, is left as it was. It already writes what stopped it and does not fail the run, and the test that follows it starts the browser through the attempts above.

Another attempt is made only when what stopped the attempt says the browser or its driver did not start, which Selenium reports as an InvalidOperationException for a session it could not create and a WebDriverException for a driver service that would not run. A fault in the caller, such as options that are wrong, is reported at once.

README.md says what the attempts are, beside the sentence on the time limits.

Tests

Helpers/SessionRetryTests.cs is new and starts no browser, so it runs in the first job of Build and test on every push and pull request.

  1. A session that starts is handed back and started once.
  2. A session the driver could not create, with the exact renderer message above, is started again and the second attempt is handed back.
  3. A driver service that would not run is started again, which is the other failure worth another attempt.
  4. When no attempt starts, every attempt is made and the failure of the last one is thrown as it stands, with its own message.
  5. A fault in the caller is reported at once and not started again.
  6. The attempts are more than one, and the attempts multiplied by the wait add up to less than 30 seconds, so a browser that will not start fails the test rather than holding the run.

Build

  • Red, run 43879029614 on tmp/retry-browser-start-red at 4ab95b2, which is these tests with SessionStartAttempts at 1, being the one attempt the code made. Exactly three of them fail, Retried_StartsAgainWhenTheSessionWasNotCreated, Retried_StartsAgainWhenTheDriverServiceWouldNotRun and SessionStartAttempts_AllowsMoreThanOneAttempt, with 55 passed and 15 skipped, so the suite built and the red is the tests rather than the build. That branch also carried a line making Build and test run on a push to it, because the workflow runs on a push to main and on a pull request only. It is deleted now the run has finished, and the run holds its log.
  • Green, run 43879328933 on this head, 323e29a. Build and test passed, and so did the three jobs that start a real Chrome and Firefox, on ubuntu-latest, ubuntu-22.04-arm and ubuntu-24.04-arm.
  • Only rc into main, run 43879329686, passed.

This repository publishes no package, so there is no Publish dry run, no version to move and nothing to time against main.

What remains

  • Fetched reports any failure on the route where the machine provides no driver as "No Chrome driver on this machine, so Selenium Manager was left to fetch one, and it could not", which reads wrongly when the real failure was a session that would not start. That is how it reads today as well, so it is left for a change of its own.
  • The language repositories clone this repository's default branch (git clone --depth 1 with no branch in each repository's ci/run-integration-tests.ps1), so these attempts reach their builds when this repository's rc reaches main, and not before.
  • No issue was open for this fault, so this closes none.

Helpers/SessionRetryTests.cs covers a session the driver did not create,
a driver service that would not run, a fault in the caller, and the
attempts a session is given.

BrowserDrivers.Retried wraps every local Chrome, Firefox and Edge
session and makes one attempt, which is what the code does today, so
three of the new tests fail.
…start

A driver that started the browser and could not reach it answers
"session not created from disconnected: unable to connect to renderer"
in about a second, which failed a test outright. Every local Chrome,
Firefox and Edge session now gets up to three attempts, two seconds
apart, and what stops the last attempt travels on as it is so the error
a test reports does not change. Each failed attempt is written to the
test's output.

A remote session on a Selenium grid is left as it was, because the grid
queues and answers its own session requests and no failure of that kind
has been measured. The first start of Chrome and Firefox is left as it
was too, since it already writes what stopped it and does not fail the
run, and the test that follows it starts the browser through the
attempts above.
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.

1 participant