intern icon indicating copy to clipboard operation
intern copied to clipboard

connect ETIMEDOUT using Intern and Browserstack

Open lzw5090 opened this issue 8 years ago • 12 comments

We are using the Intern 4 library and the dojo module for our auto-test on BrowserStack 'Automate'. The partial error log on our end as follows:

Error: [GET https://(redacted)@hub.browserstack.com:443/wd/hub/session/f5aa6f366ad78a7d820d2aa55130d5cb38241ebe/element/118/text] connect ETIMEDOUT 207.254.8.3:443
  2018-05-10T16:46:10.8989588Z at Server.get
  2018-05-10T16:46:10.8989876Z at runRequest
  2018-05-10T16:46:10.8990131Z at Task_1.default.cancelled
  2018-05-10T16:46:10.8990437Z at new Task
  2018-05-10T16:46:10.8990719Z at InitializedProxiedSession.Session._delegateToServer

It seems our test sent the REST API call but did not get anything in return therefore triggered the timeout.

Any suggestions how to fix it? Thanks very much!

lzw5090 avatar May 10 '18 22:05 lzw5090

Does this happen all the time or only with specific browsers or operating systems on BrowserStack? Are you behind a proxy?

jason0x43 avatar May 11 '18 12:05 jason0x43

I'm suffering from this problem too. It is intermittent, and it seems like actual network failure between the machine running tests and BrowserStack.

I have seen this on Chrome, Edge and IE; I'm not behind a proxy.

Right now my team is wrapping every step behind a retry to work around this issue. It'll be great if intern provides an internal retry to resolve network connection issues, or allow customizing the network timeout tolerance.

jiayexie avatar May 15 '18 18:05 jiayexie

allow customizing the network timeout tolerance

You can customize the timeouts:

  • functionalTimeouts allows you to set defaults for the initial connectTimeout (and the other functional test timeouts)
  • defaultTimeout allows you to configure the overall timeout applied to async tests

It'll be great if intern provides an internal retry to resolve network connection issues

We've been reluctant to provide an automatic retry because having to retry typically indicates a problem in the tests or a problem in the network. An actual fix would be to make the tests more robust (less timing-sensitive) or to resolve the network issue, whereas a retry feature is more of a band-aid. That's not to say we're totally against a general retry function, but we haven't seen any situations yet that couldn't be resolved in better ways.

jason0x43 avatar May 15 '18 20:05 jason0x43

Hi @jason0x43 , thanks for your prompt response. I checked my code and connectTimeout is actually set to 2 minutes; I'm surprised if that is still not enough. I will add more logging to troubleshoot that.

having to retry typically indicates a problem in the tests or a problem in the network. An actual fix would be to make the tests more robust (less timing-sensitive) or to resolve the network issue

I understand your philosophy, but the issue is we are running tests on agent machines hosted outside our control that actually experience intermittent network issues. Our tests are not time-sensitive; it is just the API call (e.g. find element; click element, or even set window size, etc.) that is timing out.

When I talk about a retry, I'm not talking about retrying a test case; I'm talking about retrying that lower-level REST API call because my network can be spotty. Does that make sense?

jiayexie avatar May 16 '18 01:05 jiayexie

I'm talking about retrying that lower-level REST API call because my network can be spotty. Does that make sense?

It does make sense, and that definitely seems like it's worth exploring.

jason0x43 avatar May 16 '18 12:05 jason0x43

Thank you! :)

jiayexie avatar May 17 '18 19:05 jiayexie

Hi @jason0x43, our connectTimeout is set as 2 minutes, but we got another "connect ETIMEDOUT" error about 20 seconds after we received the first timeout error when the API call was retrying. The config and timestamp are attached below: image

inkedretrytime_li

lzw5090 avatar May 24 '18 01:05 lzw5090

Hi @jason0x43, I decreased "connectTimeout" to a small value such as 10-10. Our test results were unaffected and the "connect ETIMEDOUT" error didn't show up. It seems "connectTimeout" not working in our test. We would highly appreciate your suggestion.

lzw5090 avatar May 25 '18 20:05 lzw5090

@jason0x43
Does this happen all the time or only with specific browsers or operating systems on BrowserStack? Are you behind a proxy?

We are not behind a proxy. This is intermittent. Our tests are running on windows 10 operating systems with Chrome, IE, and Edge. The "connect ETIMEDOUT" error shows in every browser.

lzw5090 avatar May 29 '18 19:05 lzw5090

So, the connect ETIMEDOUT errors aren't actually related to Intern's connectTimeout. Intern's option controls how long Intern will wait for the initial incoming connection from a remote browser. You would only ever see that error once per session ("Timed out waiting for remote to connect"), and if it happened the session never would end before it even got started.

The connect ETIMEDOUT error is a low-level Node error emitted when Node can't make an outgoing connection to a remote address. In this case, Intern was trying to connect to the BrowserStack hub, and your local system simply wasn't able to connect for some reason (maybe their hub was overloaded and wasn't accepting connections). The error isn't related to any particular remote browser.

This is a good use case for low-level retries in Intern. There's already some of that happing on the remote side, because we've traditionally experienced more flakiness getting back to Intern from a remote than trying to reach a remote from Intern. I created https://github.com/theintern/intern/issues/910 to track this.

jason0x43 avatar May 30 '18 13:05 jason0x43

Thanks so much!

lzw5090 avatar May 31 '18 01:05 lzw5090

Closing; this will be handled via #910

jason0x43 avatar Dec 11 '19 13:12 jason0x43