SeleniumHQ / selenium

A browser automation framework and ecosystem.
https://selenium.dev
Apache License 2.0
30.51k stars 8.15k forks source link

[🐛 Bug]: unhandled exception in grid is reported as `ScriptTimeoutException` on the client #12484

Closed joerg1985 closed 1 year ago

joerg1985 commented 1 year ago

What happened?

We had a connection issue between the standalone server and the driver, this did raise a strange exception on the client side.

org.openqa.selenium.ScriptTimeoutException: Unable to execute request for an existing session: java.net.ConnectException: Connection refused: no further information: localhost/[0:0:0:0:0:0:0:1]:42081

How can we reproduce the issue?

`org.openqa.selenium.remote.ErrorCodec.createDefault().encode(new RuntimeException())` will return:
{
  "value": {
    "error": "script timeout",
    "message": "\u003cno message present in throwable>",
    "stacktrace": "java.lang.RuntimeException\r\n\tat ..."
  }
}

I think the cause of this error is the broken filter in `ErrorCodec.fromThrowable` here:
https://github.com/SeleniumHQ/selenium/blob/c9d0e356ea2f841ee2a3268f6b70052d6cac4fd8/java/src/org/openqa/selenium/remote/ErrorCodec.java#L158

This line should be: `.filter(err -> err.exception.isAssignableFrom(throwable.getClass()))`, am i correct?

I didn't wanted to silently create a commit to fix this, as others might have seen this wired `script timeout` exception in other client bindings.

Relevant log output

CLIENT: 
org.openqa.selenium.ScriptTimeoutException: Unable to execute request for an existing session: java.net.ConnectException: Connection refused: no further information: localhost/[0:0:0:0:0:0:0:1]:42081
Build info: version: '4.9.1', revision: 'eb2032df7f'
System info: os.name: 'Windows Server 2019', os.arch: 'amd64', os.version: '10.0', java.version: '17.0.7'
Driver info: ...
Command: [ad74964c791df5b2bbc1c7588116844b, quit {}]
Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 115.0.5790.110, chrome: {chromedriverVersion: 115.0.5790.102 (90efd4b0ad6..., userDataDir: C:\Users\PID0EB7\AppData\Lo...}, goog:chromeOptions: {debuggerAddress: localhost:64387}, networkConnectionEnabled: false, pageLoadStrategy: normal, platformName: Windows 10, proxy: Proxy(), se:bidiEnabled: false, se:cdp: ws://127.0.0.1:59716/sessio..., se:cdpVersion: 115.0.5790.110, setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: ignore, webauthn:extension:credBlob: true, webauthn:extension:largeBlob: true, webauthn:extension:minPinLength: true, webauthn:extension:prf: true, webauthn:virtualAuthenticators: true}
Session ID: ad74964c791df5b2bbc1c7588116844b
jdk.internal.reflect.GeneratedConstructorAccessor19.newInstance
jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance (DelegatingConstructorAccessorImpl.java:45)
java.lang.reflect.Constructor.newInstanceWithCaller (Constructor.java:499)
java.lang.reflect.Constructor.newInstance (Constructor.java:480)
org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.createException (W3CHttpResponseCodec.java:200)
org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.decode (W3CHttpResponseCodec.java:133)
org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.decode (W3CHttpResponseCodec.java:53)
org.openqa.selenium.remote.HttpCommandExecutor.execute (HttpCommandExecutor.java:193)
com.daimler.protics.ta.driver.factory.SeleniumDrivers$1.execute (SeleniumDrivers.java:182)
org.openqa.selenium.remote.RemoteWebDriver.execute (RemoteWebDriver.java:543)
com.daimler.protics.ta.driver.factory.SeleniumDrivers$2.execute (SeleniumDrivers.java:199)
org.openqa.selenium.remote.RemoteWebDriver.execute (RemoteWebDriver.java:598)
org.openqa.selenium.remote.RemoteWebDriver.execute (RemoteWebDriver.java:602)
org.openqa.selenium.remote.RemoteWebDriver.quit (RemoteWebDriver.java:445)
...

SERVER:
java.io.UncheckedIOException: java.net.ConnectException: Connection refused: no further information: localhost/[0:0:0:0:0:0:0:1]:42081
    at org.openqa.selenium.remote.http.netty.NettyHttpHandler.makeCall(NettyHttpHandler.java:73)
    at org.openqa.selenium.remote.http.AddSeleniumUserAgent.lambda$apply$0(AddSeleniumUserAgent.java:42)
    at org.openqa.selenium.remote.http.Filter.lambda$andFinally$1(Filter.java:56)
    at org.openqa.selenium.remote.http.netty.NettyHttpHandler.execute(NettyHttpHandler.java:49)
    at org.openqa.selenium.remote.http.AddSeleniumUserAgent.lambda$apply$0(AddSeleniumUserAgent.java:42)
    at org.openqa.selenium.remote.http.Filter.lambda$andFinally$1(Filter.java:56)
    at org.openqa.selenium.remote.http.netty.NettyClient.execute(NettyClient.java:99)
    at org.openqa.selenium.remote.tracing.TracedHttpClient.execute(TracedHttpClient.java:55)
    at org.openqa.selenium.grid.web.ReverseProxyHandler.execute(ReverseProxyHandler.java:92)
    at org.openqa.selenium.grid.node.DefaultActiveSession.execute(DefaultActiveSession.java:53)
    at org.openqa.selenium.grid.node.local.SessionSlot.execute(SessionSlot.java:127)
    at org.openqa.selenium.grid.node.local.LocalNode.executeWebDriverCommand(LocalNode.java:583)
    at org.openqa.selenium.grid.node.ForwardWebDriverCommand.execute(ForwardWebDriverCommand.java:35)
    at org.openqa.selenium.remote.http.Route$PredicatedRoute.handle(Route.java:373)
    at org.openqa.selenium.remote.http.Route.execute(Route.java:68)
    at org.openqa.selenium.remote.tracing.SpanWrappedHttpHandler.execute(SpanWrappedHttpHandler.java:86)
    at org.openqa.selenium.remote.http.Filter$1.execute(Filter.java:64)
    at org.openqa.selenium.remote.http.Route$CombinedRoute.handle(Route.java:336)
    at org.openqa.selenium.remote.http.Route.execute(Route.java:68)
    at org.openqa.selenium.grid.node.Node.execute(Node.java:255)
    at org.openqa.selenium.grid.web.CombinedHandler.execute(CombinedHandler.java:59)
    at org.openqa.selenium.grid.web.RoutableHttpClientFactory$1.execute(RoutableHttpClientFactory.java:72)
    at org.openqa.selenium.grid.web.ReverseProxyHandler.execute(ReverseProxyHandler.java:92)
    at org.openqa.selenium.grid.router.HandleSession.execute(HandleSession.java:122)
    at org.openqa.selenium.remote.http.Route$PredicatedRoute.handle(Route.java:373)
    at org.openqa.selenium.remote.http.Route.execute(Route.java:68)
    at org.openqa.selenium.remote.http.Route$CombinedRoute.handle(Route.java:336)
    at org.openqa.selenium.remote.http.Route.execute(Route.java:68)
    at org.openqa.selenium.grid.router.Router.execute(Router.java:91)
    at org.openqa.selenium.grid.web.CheckOriginHeader.lambda$apply$0(CheckOriginHeader.java:66)
    at org.openqa.selenium.grid.web.CheckContentTypeHeader.lambda$apply$0(CheckContentTypeHeader.java:70)
    at org.openqa.selenium.grid.web.EnsureSpecCompliantResponseHeaders.lambda$apply$0(EnsureSpecCompliantResponseHeaders.java:34)
    at org.openqa.selenium.remote.http.Filter$1.execute(Filter.java:64)
    at org.openqa.selenium.remote.http.Route$CombinedRoute.handle(Route.java:336)
    at org.openqa.selenium.remote.http.Route.execute(Route.java:68)
    at org.openqa.selenium.remote.http.Route$NestedRoute.handle(Route.java:270)
    at org.openqa.selenium.remote.http.Route.execute(Route.java:68)
    at org.openqa.selenium.remote.http.Route$CombinedRoute.handle(Route.java:336)
    at org.openqa.selenium.remote.http.Route.execute(Route.java:68)
    at org.openqa.selenium.remote.http.Route$CombinedRoute.handle(Route.java:336)
    at org.openqa.selenium.remote.http.Route.execute(Route.java:68)
    at org.openqa.selenium.remote.http.Route$CombinedRoute.handle(Route.java:336)
    at org.openqa.selenium.remote.http.Route.execute(Route.java:68)
    at org.openqa.selenium.remote.http.Route$CombinedRoute.handle(Route.java:336)
    at org.openqa.selenium.remote.http.Route.execute(Route.java:68)
    at org.openqa.selenium.remote.AddWebDriverSpecHeaders.lambda$apply$0(AddWebDriverSpecHeaders.java:35)
    at org.openqa.selenium.remote.ErrorFilter.lambda$apply$0(ErrorFilter.java:44)
    at org.openqa.selenium.remote.http.Filter$1.execute(Filter.java:64)
    at org.openqa.selenium.remote.ErrorFilter.lambda$apply$0(ErrorFilter.java:44)
    at org.openqa.selenium.remote.http.Filter$1.execute(Filter.java:64)
    at org.openqa.selenium.netty.server.SeleniumHandler.lambda$channelRead0$0(SeleniumHandler.java:44)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    at java.base/java.lang.Thread.run(Thread.java:833)

Operating System

Windows 10 x64

Selenium version

Java 4.9.1

What are the browser(s) and version(s) where you see this issue?

all

What are the browser driver(s) and version(s) where you see this issue?

all

Are you using Selenium Grid?

standalone 4.9.1

github-actions[bot] commented 1 year ago

@joerg1985, thank you for creating this issue. We will troubleshoot it as soon as we can.


Info for maintainers

Triage this issue by using labels.

If information is missing, add a helpful comment and then I-issue-template label.

If the issue is a question, add the I-question label.

If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.

If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C), add the applicable G-* label, and it will provide the correct link and auto-close the issue.

After troubleshooting the issue, please add the R-awaiting answer label.

Thank you!

joerg1985 commented 1 year ago

@diemol could you have a look at the suggested fix for this?

diemol commented 1 year ago

@joerg1985 I believe you are correct. Feel free to push the fix, thank you!

joerg1985 commented 1 year ago

has been fixed in https://github.com/SeleniumHQ/selenium/commit/c62fe6c6943caa1b0543596539b0695ffe8e66cc, with some other small issues.

github-actions[bot] commented 10 months ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.