From c6f6deb134bd74f02e20d740147a6aae920fec23 Mon Sep 17 00:00:00 2001 From: Dmitry Vorotilin Date: Sun, 15 Nov 2026 18:46:49 +0300 Subject: [PATCH] fix(page): call client.command inside wait_for_navigation! so a command override runs once Page#command(wait:) called command again in the block, which ran a subclass override such as Cuprite's twice. Call client.command there, after the slowmo sleep. --- CHANGELOG.md | 1 + lib/ferrum/page.rb | 13 ++++++------- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f80aba86..8c4f956b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,7 @@ `go_to` instead ### Fixed +- `page.command(method, wait:)` ran a subclass override of `command`, like Cuprite's, twice - `evaluate` of a result nested about 100 levels deep raised an opaque `BrowserError` about Chrome's CBOR stack limit, it raises `ResultTooDeepError` now, a `BrowserError` that says to return less or use `evaluate_handle` - `worker.close` never closed a dedicated worker, Chrome refuses to close it from outside, it closes itself now diff --git a/lib/ferrum/page.rb b/lib/ferrum/page.rb index 83daf44d..884f34ee 100644 --- a/lib/ferrum/page.rb +++ b/lib/ferrum/page.rb @@ -554,14 +554,13 @@ def activate # page.command("Page.navigate", url: "https://github.com/") # def command(method, wait: 0, slowmoable: false, timeout: nil, **params) - if wait.positive? - result = nil - wait_for_navigation!(wait) { result = command(method, slowmoable:, timeout:, **params) } - return result - end - sleep(@options.slowmo) if slowmoable && @options.slowmo.positive? - client.command(method, timeout: timeout || self.timeout, **params) + timeout ||= self.timeout + return client.command(method, timeout:, **params) unless wait.positive? + + result = nil + wait_for_navigation!(wait) { result = client.command(method, timeout:, **params) } + result end # Subscribes to a CDP event, or to `:dialog`, `:request`, `:response`,