1

Googling yielded nothing but source code on this timeout and I seem to have no visibility via logs looking at selenium source code. I am wondering if anyone else has run into this issue with selenium

The condition we waited on was the following

WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(30));
wait.until(ExpectedConditions.titleContains("Find a doctor"));

org.openqa.selenium.TimeoutException: Supplied function might have stalled
Build info: version: '4.0.0-alpha-5', revision: 'b3a0d621cc'
System info: host: 'localhost', ip: '127.0.0.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.0', java.version: '11.0.6'
Driver info: driver.version: unknown
    at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:221)
    at com.orderlyhealth.scraper.json.CaredashHelper.getSearchResultsFromProviderImpl(CaredashHelper.java:320)
    at com.orderlyhealth.scraper.json.CaredashHelper.getSearchResultsFromProvider(CaredashHelper.java:294)
    at com.orderlyhealth.scraper.json.CaredashHelper.runImpl(CaredashHelper.java:65)
    at com.orderlyhealth.scraper.json.CaredashHelper.run(CaredashHelper.java:57)
    at com.orderlyhealth.scraper.json.JsonController.runBatchImpl(JsonController.java:200)
    at com.orderlyhealth.scraper.json.JsonController.executeBatch(JsonController.java:134)
    at com.orderlyhealth.scraper.json.JsonController.preRunBatchImpl(JsonController.java:110)
    at com.orderlyhealth.scraper.json.JsonController.runBatch(JsonController.java:86)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.base/java.lang.reflect.Method.invoke(Unknown Source)
    at org.webpieces.router.impl.services.ControllerInvoker.invokeController(ControllerInvoker.java:30)
    at org.webpieces.router.impl.services.SvcProxyForContent.invokeAndCoerce(SvcProxyForContent.java:56)
    at org.webpieces.router.impl.services.SvcProxyForContent.lambda$invokeMethod$1(SvcProxyForContent.java:49)
    at java.base/java.util.concurrent.CompletableFuture.uniComposeStage(Unknown Source)
    at java.base/java.util.concurrent.CompletableFuture.thenCompose(Unknown Source)
    at org.webpieces.router.impl.services.SvcProxyForContent.invokeMethod(SvcProxyForContent.java:49)
    at org.webpieces.router.impl.services.SvcProxyForContent.lambda$invoke$0(SvcProxyForContent.java:33)
    at org.webpieces.util.futures.FutureHelper.syncToAsyncException(FutureHelper.java:169)
    at org.webpieces.router.impl.services.SvcProxyForContent.invoke(SvcProxyForContent.java:33)
    at org.webpieces.router.impl.services.SvcProxyForContent.invoke(SvcProxyForContent.java:19)
    at com.orderlyhealth.serverutil.filters.InternalSvcValidationFilter.filter(InternalSvcValidationFilter.java:33)
    at com.orderlyhealth.serverutil.filters.InternalSvcValidationFilter.filter(InternalSvcValidationFilter.java:13)
    at org.webpieces.router.impl.loader.ChainFilters$ServiceFilterProxy.invoke(ChainFilters.java:29)
    at org.webpieces.router.impl.loader.ChainFilters$ServiceFilterProxy.invoke(ChainFilters.java:17)
    at org.webpieces.plugin.json.JacksonCatchAllFilter.filter(JacksonCatchAllFilter.java:44)
    at org.webpieces.plugin.json.JacksonCatchAllFilter.filter(JacksonCatchAllFilter.java:28)
    at org.webpieces.router.impl.loader.ChainFilters$ServiceFilterProxy.invoke(ChainFilters.java:29)
    at org.webpieces.router.impl.loader.ChainFilters$ServiceFilterProxy.invoke(ChainFilters.java:17)
    at com.orderlyhealth.serverutil.filters.JobAndBatchIdFilter.filter(JobAndBatchIdFilter.java:33)
    at com.orderlyhealth.serverutil.filters.JobAndBatchIdFilter.filter(JobAndBatchIdFilter.java:13)
    at org.webpieces.router.impl.loader.ChainFilters$ServiceFilterProxy.invoke(ChainFilters.java:29)
    at org.webpieces.router.impl.loader.ChainFilters$ServiceFilterProxy.invoke(ChainFilters.java:17)
    at org.webpieces.router.impl.routers.Endpoint.invoke(Endpoint.java:27)
    at org.webpieces.router.impl.routeinvoker.ServiceInvoker.invokeService(ServiceInvoker.java:83)
    at org.webpieces.router.impl.routeinvoker.ServiceInvoker.lambda$invokeSvc$0(ServiceInvoker.java:67)
    at org.webpieces.util.futures.FutureHelper.syncToAsyncException(FutureHelper.java:169)
    at org.webpieces.util.futures.FutureHelper.catchBlock(FutureHelper.java:104)
    at org.webpieces.util.futures.FutureHelper.catchBlockWrap(FutureHelper.java:142)
    at org.webpieces.router.impl.routeinvoker.ServiceInvoker.invokeSvc(ServiceInvoker.java:66)
    at org.webpieces.router.impl.routebldr.RequestResponseStream.lambda$openStream$1(RequestResponseStream.java:57)
    at org.webpieces.router.impl.routeinvoker.RequestStreamWriter2.handleCompleteRequestImpl(RequestStreamWriter2.java:86)
    at org.webpieces.router.impl.routeinvoker.RequestStreamWriter2.processPiece(RequestStreamWriter2.java:68)
    at org.webpieces.router.impl.routers.NonStreamingWebAppErrorProxy.lambda$processPiece$0(NonStreamingWebAppErrorProxy.java:41)
    at org.webpieces.util.futures.FutureHelper.syncToAsyncException(FutureHelper.java:169)
    at org.webpieces.util.futures.FutureHelper.catchBlock(FutureHelper.java:104)
    at org.webpieces.router.impl.routers.NonStreamingWebAppErrorProxy.processPiece(NonStreamingWebAppErrorProxy.java:40)
    at org.webpieces.router.impl.TxStreamWriter.processPiece(TxStreamWriter.java:24)
    at org.webpieces.frontend2.impl.ProxyHttpStream$ProxyWriter.processPiece(ProxyHttpStream.java:161)
    at org.webpieces.frontend2.impl.Layer2Http11Handler.lambda$processPiece$7(Layer2Http11Handler.java:210)
    at java.base/java.util.concurrent.CompletableFuture.uniComposeStage(Unknown Source)
    at java.base/java.util.concurrent.CompletableFuture.thenCompose(Unknown Source)
    at org.webpieces.frontend2.impl.Layer2Http11Handler.processPiece(Layer2Http11Handler.java:210)
    at org.webpieces.frontend2.impl.Layer2Http11Handler.lambda$null$4(Layer2Http11Handler.java:199)
    at org.webpieces.util.futures.FutureHelper.syncToAsyncException(FutureHelper.java:169)
    at org.webpieces.util.futures.FutureHelper.finallyBlock(FutureHelper.java:55)
    at org.webpieces.frontend2.impl.Layer2Http11Handler.lambda$processData$6(Layer2Http11Handler.java:198)
    at org.webpieces.util.locking.PermitQueue.processItemFromQueue(PermitQueue.java:82)
    at org.webpieces.util.locking.PermitQueue.runRequest(PermitQueue.java:62)
    at org.webpieces.frontend2.impl.Layer2Http11Handler.processData(Layer2Http11Handler.java:184)
    at org.webpieces.frontend2.impl.Layer2Http11Handler.processCorrectly(Layer2Http11Handler.java:173)
    at org.webpieces.frontend2.impl.Layer2Http11Handler.lambda$processWithBackpressure$3(Layer2Http11Handler.java:149)
    at java.base/java.util.concurrent.CompletableFuture.uniComposeStage(Unknown Source)
    at java.base/java.util.concurrent.CompletableFuture.thenCompose(Unknown Source)
    at org.webpieces.frontend2.impl.Layer2Http11Handler.processWithBackpressure(Layer2Http11Handler.java:149)
    at org.webpieces.frontend2.impl.Layer2Http11Handler.initialDataImpl(Layer2Http11Handler.java:72)
    at org.webpieces.frontend2.impl.Layer2Http11Handler.initialData(Layer2Http11Handler.java:48)
    at org.webpieces.frontend2.impl.Layer1ServerListener.lambda$initialData$1(Layer1ServerListener.java:62)
    at org.webpieces.util.futures.FutureHelper.syncToAsyncException(FutureHelper.java:169)
    at org.webpieces.util.futures.FutureHelper.catchBlock(FutureHelper.java:104)
    at org.webpieces.util.futures.FutureHelper.catchBlockWrap(FutureHelper.java:142)
    at org.webpieces.frontend2.impl.Layer1ServerListener.initialData(Layer1ServerListener.java:61)
    at org.webpieces.frontend2.impl.Layer1ServerListener.incomingData(Layer1ServerListener.java:51)
    at org.webpieces.asyncserver.impl.ProxyDataListener.incomingData(ProxyDataListener.java:26)
    at org.webpieces.nio.impl.threading.ThreadDataListener$DataListeneRunanble.run(ThreadDataListener.java:54)
    at org.webpieces.util.threading.SessionExecutorImpl$RunnableWithKey.run(SessionExecutorImpl.java:121)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.base/java.lang.Thread.run(Unknown Source)
Caused by: java.util.concurrent.TimeoutException: null
    at java.base/java.util.concurrent.CompletableFuture.timedGet(Unknown Source)
    at java.base/java.util.concurrent.CompletableFuture.get(Unknown Source)
    at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:209)
            ... 80 common frames omitted

Any ideas how to fix this? It is happens quite a bit to us.

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
Dean Hiller
  • 19,235
  • 25
  • 129
  • 212
  • Is the issue specifically on moving to Java-11 or just that it happened to be the version installed on your system? – Naman Jun 25 '20 at 03:20
  • Do you observe this in alpha-4 ? There are changes in implementation of until method from aplha-5. Its using 'CompletableFuture.supplyAsync(.. https://github.com/SeleniumHQ/selenium/commit/51de5363808d6ee3c5c93cc5f36f91e17aed4ceb' – Rahul L Jun 25 '20 at 08:08

3 Answers3

1

This error message...

org.openqa.selenium.TimeoutException: Supplied function might have stalled
Build info: version: '4.0.0-alpha-5', revision: 'b3a0d621cc'
System info: host: 'localhost', ip: '127.0.0.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.0', java.version: '11.0.6'
Driver info: driver.version: unknown

...implies that TimeoutException occurred while waiting for title to contain the string Find a doctor.


Analysis

I don't see any major change in the defination of the ExpectedConditions titleContains() which is defined as follows:

/**
 * An expectation for checking that the title contains a case-sensitive substring
 *
 * @param title the fragment of title expected
 * @return true when the title matches, false otherwise
 */
public static ExpectedCondition<Boolean> titleContains(final String title) {
  return new ExpectedCondition<Boolean>() {
    private String currentTitle = "";

    @Override
    public Boolean apply(WebDriver driver) {
      currentTitle = driver.getTitle();
      return currentTitle != null && currentTitle.contains(title);
    }

    @Override
    public String toString() {
      return String.format("title to contain \"%s\". Current title: \"%s\"", title, currentTitle);
    }
  };
}

However the TimeoutException seems to be arising from ExecutionException which looks a bit odd.

/**
 * Repeatedly applies this instance's input value to the given function until one of the following
 * occurs:
 * <ol>
 * <li>the function returns neither null nor false</li>
 * <li>the function throws an unignored exception</li>
 * <li>the timeout expires</li>
 * <li>the current thread is interrupted</li>
 * </ol>
 *
 * @param isTrue the parameter to pass to the {@link ExpectedCondition}
 * @param <V>    The function's expected return type.
 * @return The function's return value if the function returned something different
 * from null or false before the timeout expired.
 * @throws TimeoutException If the timeout expires.
 */
@Override
public <V> V until(Function<? super T, V> isTrue) {
  try {
    return CompletableFuture.supplyAsync(checkConditionInLoop(isTrue))
        .get(deriveSafeTimeout(), TimeUnit.MILLISECONDS);
  } catch (ExecutionException cause) {
    if (cause.getCause() instanceof RuntimeException) {
      throw (RuntimeException) cause.getCause();
    } else if (cause.getCause() instanceof Error) {
      throw (Error) cause.getCause();
    }

    throw new RuntimeException(cause);
  } catch (InterruptedException cause) {
    Thread.currentThread().interrupt();
    throw new RuntimeException(cause);
  } catch (java.util.concurrent.TimeoutException cause) {
    throw new TimeoutException("Supplied function might have stalled", cause);
  }
}

But driver.version: unknown gives us a hint that there is a incompatibility between the version of the binaries you are using.

Additionally, in the next release of Selenium, the constructor of WebDriverWait of would be deprecated.

@Deprecated
public WebDriverWait(WebDriver driver, long timeoutInSeconds) {
  this(driver, Duration.ofSeconds(timeoutInSeconds));
}

The new constructor of WebDriverWait to be used in (currently in Alpha) is:

public WebDriverWait(WebDriver driver, Duration timeout) {
  this(
      driver,
      timeout,
      Duration.ofMillis(DEFAULT_SLEEP_TIMEOUT),
      Clock.systemDefaultZone(),
      Sleeper.SYSTEM_SLEEPER);
}

The usage should be:

new WebDriverWait(driver, Duration.ofSeconds(10));

Java 11

As you are using java.version: '11.0.6', Selenium is still not compatible with Java 11. But once Java 11 ships and Buck supports it the toolchain witll be rejiged to support Java 11.


Solution

The strategic solution will be to install the latest version of JDK 8u251 and execute the @Tests


Reference

You can find a relevant detailed discussion in Unable to import org.openqa.selenium.WebDriver using Selenium and Java 11

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • I am also seeing this same ERROR with Java 1.8.0_221 `ERROR 2021-09-13 14:21:18,600 [TestNG-tests-1] com.cubic.accelerators.WebDriverActions - org.openqa.selenium.TimeoutException: Supplied function might have stalled Build info: version: '4.0.0-alpha-6', revision: '5f43a29cfc' System info: host: 'WL200836', ip: '10.63.10.2', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_221' Driver info: driver.version: unknown at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:221)` – Asanke Sep 13 '21 at 04:29
1

Turns out when you have a bad proxy in the middle, I noticed the browsers would WAIT on the page. This then would cause selenium drivers to hang. It was a very intermittent issue so hard to narrow down to a proxy issue.

Dean Hiller
  • 19,235
  • 25
  • 129
  • 212
0

it is saying clearly i.e TimeoutException, change the timeout ,you given 30 ms but actually need more than that...give it as more than 30 , it will work smoothly.