Skip to content

Commit 472d170

Browse files
committed
just switch to logging errors instead of propagating them
1 parent 481e0d7 commit 472d170

File tree

5 files changed

+8
-24
lines changed

5 files changed

+8
-24
lines changed

rb/lib/selenium/webdriver/bidi.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class BiDi
3232
autoload :InterceptedItem, 'selenium/webdriver/bidi/network/intercepted_item'
3333

3434
def initialize(url:)
35-
@ws = WebSocketConnection.new(url: url, protocol: :bidi)
35+
@ws = WebSocketConnection.new(url: url)
3636
end
3737

3838
def close

rb/lib/selenium/webdriver/common/websocket_connection.rb

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class WebSocketConnection
3535

3636
MAX_LOG_MESSAGE_SIZE = 9999
3737

38-
def initialize(url:, protocol: nil)
38+
def initialize(url:)
3939
@callback_threads = ThreadGroup.new
4040

4141
@callbacks_mtx = Mutex.new
@@ -45,7 +45,6 @@ def initialize(url:, protocol: nil)
4545
@closing = false
4646
@session_id = nil
4747
@url = url
48-
@protocol = protocol
4948

5049
process_handshake
5150
@socket_thread = attach_socket_listener
@@ -178,12 +177,6 @@ def callback_thread(params)
178177
rescue StandardError => e
179178
return if @closing
180179

181-
if devtools?
182-
# Async thread exceptions are not deterministic and should not be relied on; we should stop
183-
WebDriver.logger.deprecate('propogating errors from DevTools callbacks')
184-
Thread.main.raise(e)
185-
end
186-
187180
bt = Array(e.backtrace).first(5).join("\n")
188181
WebDriver.logger.error "Callback error: #{e.class}: #{e.message}\n#{bt}", id: :ws
189182
end
@@ -210,14 +203,6 @@ def ws
210203
@ws ||= WebSocket::Handshake::Client.new(url: @url)
211204
end
212205

213-
def devtools?
214-
@protocol == :devtools
215-
end
216-
217-
def bidi?
218-
@protocol == :bidi
219-
end
220-
221206
def next_id
222207
@id ||= 0
223208
@id += 1

rb/lib/selenium/webdriver/devtools.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class DevTools
2929
autoload :Response, 'selenium/webdriver/devtools/response'
3030

3131
def initialize(url:, target_type:)
32-
@ws = WebSocketConnection.new(url: url, protocol: :devtools)
32+
@ws = WebSocketConnection.new(url: url)
3333
@session_id = nil
3434
start_session(target_type: target_type)
3535
end

rb/spec/integration/selenium/webdriver/devtools_spec.rb

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,12 @@ module WebDriver
4545
}.to yield_control
4646
end
4747

48-
it 'propagates errors in events' do
48+
it 'logs errors in events' do
49+
driver.devtools.page.enable
50+
driver.devtools.page.on(:load_event_fired) { raise 'This is fine!' }
4951
expect {
50-
driver.devtools.page.enable
51-
driver.devtools.page.on(:load_event_fired) { raise 'This is fine!' }
5252
driver.navigate.to url_for('xhtmlTest.html')
53-
sleep 0.5
54-
}.to raise_error(RuntimeError, 'This is fine!')
53+
}.to have_error(:ws, /This is fine!/)
5554
end
5655

5756
describe '#target' do

rb/spec/rspec_matchers.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
# specific language governing permissions and limitations
1818
# under the License.
1919

20-
LEVELS = %w[warning info deprecated].freeze
20+
LEVELS = %w[error warning info deprecated].freeze
2121

2222
LEVELS.each do |level|
2323
RSpec::Matchers.define "have_#{level}" do |entry|

0 commit comments

Comments
 (0)