Skip to content

Commit 2c87a24

Browse files
小野 直人ko1
authored andcommitted
Make sure that $stdout returns to its original value after evaluation in CDP
1 parent 183b409 commit 2c87a24

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/debug/server_cdp.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -422,12 +422,14 @@ def process_cdp args
422422
when :evaluate
423423
expr = args.shift
424424
begin
425+
orig_stdout = $stdout
425426
$stdout = StringIO.new
426427
result = current_frame.binding.eval(expr.to_s, '(DEBUG CONSOLE)')
427-
output = $stdout.string
428-
$stdout = STDOUT
429428
rescue Exception => e
430429
result = e
430+
ensure
431+
output = $stdout.string
432+
$stdout = orig_stdout
431433
end
432434
event! :cdp_result, :evaluate, req, result: evaluate_result(result), output: output
433435
when :properties

0 commit comments

Comments
 (0)