Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enforce BrowserStack build requests to use port 443. #4282

Merged
merged 2 commits into from
Oct 25, 2024

Conversation

garg3133
Copy link
Member

When using Nightwatch with BrowserStack, the following error occurred in certain cases when trying to get builds data from BrowserStack or send the test results at the end of the test run:

Error                                                                      
   GET https://api.browserstack.com:4444                                      
   /automate/builds.json?status=running - ETIMEDOUT                           
   AggregateError                                                             
   at internalConnectMultiple (node:net:1122:18)                              
   at internalConnectMultiple (node:net:1190:5)                               
   at Timeout.internalConnectMultipleTimeout (node:net:1716:5)

Error Reproduction

As I was trying to reproduce this, when I changed the port at which we connect to the Selenium grid from 443 to 4444, the build-related requests to BrowserStack started failing for me as well, but with a different error:

TypeError [ERR_INVALID_PROTOCOL]: Protocol "https:" not supported. Expected "http:"

On investigating this further, while still trying to reproduce the original error, I found that the above ERR_INVALID_PROTOCOL error was occurring because of the user-agent being set for the requests -- Nightwatch only sets the user-agent protocol as https if the request is being made to the port 443, otherwise the protocol is always set to http (something we should fix), and due to this mismatch (https request being sent with http user-agent), the above error was being encountered.

Also, I found that the user-agent was getting set only if the keep-alive property was set to true. So, as soon as I switched the keep-alive property to false, I was able to reproduce the original error.

Fix

The root cause of the original error is that the https://api.browserstack.com website does not listen on any port other than 443. So, this PR enforces all the BrowserStack build-related requests to be made to the port 443 instead of the port used for communicating with BrowserStack Selenium grid.

Copy link

Status

  • ❌ No modified files found in the types directory.
    Please make sure to include types for any changes you have made. Thank you!.

@garg3133 garg3133 merged commit 473cf11 into nightwatchjs:main Oct 25, 2024
15 of 17 checks passed
@garg3133 garg3133 deleted the browserstack-timedout-issue branch October 25, 2024 14:42
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