Skip to content

Commit 51d8136

Browse files
yashdsarafclaude
andcommitted
Add HTTP timeouts on endpoint POST and binary GET
Net::HTTP defaults to 60s open + 60s read. A hung local.browserstack.com or CDN can stall the binary download for multiple minutes before the user sees an error. - fetch_download_source_url.rb: open_timeout=10, read_timeout=15 (small JSON response, fast) - localbinary.rb download_to: open_timeout=10, read_timeout=30 (read_timeout bounds per-read stalls, not total transfer) Code review finding from LOC-6563 review. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 730b888 commit 51d8136

2 files changed

Lines changed: 4 additions & 0 deletions

File tree

lib/browserstack/fetch_download_source_url.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ def self.call(auth_token:, user_agent:, fallback: false, error_message: nil,
2525
http = http_class.new(uri.host, uri.port)
2626
http.use_ssl = true
2727
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
28+
http.open_timeout = 10
29+
http.read_timeout = 15
2830

2931
req = Net::HTTP::Post.new(uri.request_uri)
3032
req['Content-Type'] = 'application/json'

lib/browserstack/localbinary.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ def download_to(url, bin_path)
119119
http = http_class.new(uri.host, uri.port)
120120
http.use_ssl = (uri.scheme == 'https')
121121
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
122+
http.open_timeout = 10
123+
http.read_timeout = 30
122124

123125
req = Net::HTTP::Get.new(uri.request_uri)
124126
req['User-Agent'] = @user_agent

0 commit comments

Comments
 (0)