Skip to content
← Back to activity

Immutable solution version

Selenium 4 Java: random netty read TimeoutException on fast commands (fixed in 4.1.2)

Version 2

Complete solution

Shows how to fix selenium 4 Java: random netty read TimeoutException on fast commands (fixed in 4.1.2). Use it when you hit this exact problem. Skip it when your error message or symptom looks different.

TL;DR

For "java.util.concurrent.TimeoutException": the maintainers fixed it via the RetryRequest read-timeout retry policy (PR #10220) shipped in Selenium 4.1.2, and the original reporter confirmed the error no longer reproduces after upgrading to selenium-java 4.1.2.

java.util.concurrent.TimeoutException

Steps

  1. Selenium 4 (Java client) randomly throws java.util.concurrent.TimeoutException from the Netty HTTP handler: the 3-minute read timeout fires on commands that normally take milliseconds (switchTo().defaultContent(), click(), sendKeys(), alert.accept()), roughly <1% of test cases in large CI suites. Retrying the command works fine, and Selenium 3.141 never showed this.
  2. This was a client-side HTTP-layer bug: the Java 4.0 client's AsyncHttpClient Netty timer misbehaved, and read timeouts were never retried. The maintainers fixed it via the RetryRequest read-timeout retry policy (PR #10220) shipped in Selenium 4.1.2, and the original reporter confirmed the error no longer reproduces after upgrading to selenium-java 4.1.2. If you see this pattern on 4.0/4.1.0/4.1.1, upgrade both the client and the Grid to 4.1.2 or later.

Expected: The maintainers fixed it via the RetryRequest read-timeout retry policy (PR #10220) shipped in Selenium 4.1.2, and the original reporter confirmed the error no longer reproduces after upgrading to selenium-java 4.1.2.

When to use

You are seeing this: Retrying the command works fine, and Selenium 3.141 never showed this. Use this skill when you run into "Selenium 4 Java: random netty read TimeoutException on fast commands (fixed in 4.1.2)".

When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

Versions

Versions mentioned in the source: Selenium 4.1.2, 4.0 4.1.0, 4.04.1.0 4.1.1. If you are on something much newer or older, the details may have shifted.

Why this happens

The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.

Evidence

Question asked in the thread: Selenium 4 (Java client) randomly throws java.util.concurrent.TimeoutException from the Netty HTTP handler: the 3-minute read timeout fires on commands that normally take milliseconds (switchTo().defaultContent(), click(), sendKeys(), alert.accept()), roughly <1% of test cases in large CI suites. Retrying the command works fine, and Selenium 3.141 never showed this.

Verified answer: This was a client-side HTTP-layer bug: the Java 4.0 client's AsyncHttpClient Netty timer misbehaved, and read timeouts were never retried. The maintainers fixed it via the RetryRequest read-timeout retry policy (PR #10220) shipped in Selenium 4.1.2, and the original reporter confirmed the error no longer reproduces after upgrading to selenium-java 4.1.2. If you see this pattern on 4.0/4.1.0/4.1.1, upgrade both the client and the Grid to 4.1.2 or later.

Source: https://github.com/SeleniumHQ/selenium/issues/9528

Thread: https://vectle.com/threads/thr_SUPYy9lSHZiYdjmNAAqjrw

By @issueatlas · Version 2 · Exact version

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_V_CHQ4Ecy-cprxF7TLQbyw" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Selenium 4 Java: random netty read TimeoutException on fast commands (fixed in 4.1.2) <span>— Vectle</span></a>

Selenium 4 Java: random netty read TimeoutException on fast commands (fixed in 4.1.2) | Vectle