@@ -304,9 +304,10 @@ def execute_dap_scenario scenario
304304 @remote_info &.w &.close
305305 end
306306
307- def execute_cdp_scenario scenario
307+ def execute_cdp_scenario_ scenario
308308 ENV [ 'RUBY_DEBUG_TEST_UI' ] = 'chrome'
309309
310+ @web_sock = nil
310311 @remote_info = setup_tcpip_remote_debuggee
311312 Timeout . timeout ( TIMEOUT_SEC ) do
312313 sleep 0.001 until @remote_info . debuggee_backlog . join . include? @remote_info . port . to_s
@@ -329,6 +330,23 @@ def execute_cdp_scenario scenario
329330 @remote_info &.w &.close
330331 end
331332
333+ def execute_cdp_scenario scenario
334+ retry_cnt = 0
335+ begin
336+ execute_cdp_scenario_ scenario
337+ rescue Errno ::ECONNREFUSED
338+ if ( retry_cnt += 1 ) > 10
339+ STDERR . puts "retry #{ retry_cnt } but can not connect!"
340+ raise
341+ end
342+
343+ STDERR . puts "retry (#{ retry_cnt } ) connecting..."
344+
345+ sleep 0.3
346+ retry
347+ end
348+ end
349+
332350 def req_disconnect
333351 case get_target_ui
334352 when 'vscode'
@@ -399,21 +417,7 @@ def attach_to_cdp_server
399417 sleep 0.001 until @remote_info . debuggee_backlog . join . include? 'Disconnected.'
400418 end
401419
402- retry_cnt = 0
403- begin
404- sock = Socket . tcp HOST , @remote_info . port
405- rescue Errno ::ECONNREFUSED
406- if ( retry_cnt += 1 ) > 20
407- STDERR . puts "retry #{ retry_cnt } but can not connect..."
408- raise
409- end
410-
411- STDERR . puts "retry (#{ retry_cnt } ) connecting to #{ HOST } :#{ @remote_info . port } "
412-
413- sleep 0.3
414- retry
415- end
416-
420+ sock = Socket . tcp HOST , @remote_info . port
417421 uuid = body [ 0 ] [ :id ]
418422
419423 Timeout . timeout ( TIMEOUT_SEC ) do
0 commit comments