Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
mobile device's viewport and touch support together. [#94]

### Changed
- `:protocol_timeout` defaults to 30 seconds instead of following `:timeout`. Internal CDP calls resolve in
milliseconds, so the old default made `timeout: 1` shorten browser bookkeeping too and turned a loaded machine
into `Ferrum::TimeoutError` during page creation [#470]
- `Ferrum::Page::Stream#stream` now closes the CDP stream handle (`IO.close`) once it's been fully read, so streams
opened for `Ferrum::Browser#pdf` and `Ferrum::Page::Tracing#record` no longer keep their backing storage alive in
the browser; a failed `IO.close` is raised to the caller.
Expand Down
7 changes: 6 additions & 1 deletion docs/2-customization.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ Ferrum::Browser.new(options)
* `:slowmo` (Integer | Float) - Set a delay in seconds to wait before sending command.
Useful companion of headless option, so that you have time to see changes.
* `:timeout` (Numeric) - The number of seconds we'll wait for a response when
communicating with browser. Default is 5.
communicating with browser: navigations, JS evaluation, DOM queries,
dispatching input, etc. Default is 5.
* `:protocol_timeout` (Numeric) - The number of seconds we'll wait for an
internal CDP bookkeeping call to respond, e.g. `Target.createTarget`.
They normally resolve in milliseconds, so this only runs out when the
machine is heavily loaded. Default is 30.
* `:js_errors` (Boolean) - When true, JavaScript errors get re-raised in Ruby.
* `:pending_connection_errors` (Boolean) - Raise `PendingConnectionsError` when main frame is still waiting
for slow responses and timeout is reached. Default is false.
Expand Down
6 changes: 4 additions & 2 deletions lib/ferrum/browser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,12 @@ class Browser
# The number of seconds we'll wait for a response when communicating
# with the browser: navigations, JS evaluation, DOM queries, dispatching input, etc.
#
# @option options [Numeric] :protocol_timeout (5)
# @option options [Numeric] :protocol_timeout (30)
# The number of seconds we'll wait for an individual internal CDP
# bookkeeping call to respond, e.g. `Target.createTarget`,
# `Target.attachToTarget`. These normally resolve in milliseconds.
# `Target.attachToTarget`. These normally resolve in milliseconds, the
# budget is generous because exceeding it means the machine is loaded,
# not that the browser is gone, that case is detected on its own.
#
# @option options [Boolean] :js_errors
# When true, JavaScript errors get re-raised in Ruby.
Expand Down
2 changes: 1 addition & 1 deletion lib/ferrum/browser/options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Options
WINDOW_SIZE = [1024, 768].freeze
BASE_URL_SCHEMA = %w[http https].freeze
DEFAULT_TIMEOUT = ENV.fetch("FERRUM_DEFAULT_TIMEOUT", 5).to_i
DEFAULT_PROTOCOL_TIMEOUT = ENV.fetch("FERRUM_PROTOCOL_TIMEOUT", DEFAULT_TIMEOUT).to_i
DEFAULT_PROTOCOL_TIMEOUT = ENV.fetch("FERRUM_PROTOCOL_TIMEOUT", 30).to_i
PROCESS_TIMEOUT = ENV.fetch("FERRUM_PROCESS_TIMEOUT", 10).to_i
DEBUG_MODE = !ENV.fetch("FERRUM_DEBUG", nil).nil?

Expand Down
13 changes: 13 additions & 0 deletions spec/browser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,19 @@
browser&.quit
end

it "supports :protocol_timeout argument" do
browser = Ferrum::Browser.new(base_url: base_url, timeout: 1)

expect(browser.timeout).to eq(1)
expect(browser.protocol_timeout).to eq(30)

browser.protocol_timeout = 2

expect(browser.protocol_timeout).to eq(2)
ensure
browser&.quit
end

it "supports :process_timeout argument" do
path = "#{PROJECT_ROOT}/spec/support/no_chrome"

Expand Down
Loading