Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Continue the debuggee after detaching to Chrome #381

Merged
merged 1 commit into from
Nov 25, 2021
Merged

Conversation

ono-max
Copy link
Member

@ono-max ono-max commented Nov 10, 2021

Description

Currently, when a tab in Chrome DevTools is closed, the error occurs such as:

Before

DEBUGGER: Debugger can attach via TCP/IP (127.0.0.1:12345)
DEBUGGER: With Chrome browser, type the following URL in the address-bar:

   devtools://devtools/bundled/inspector.html?ws=127.0.0.1:12345

DEBUGGER: wait for debugger connection...
DEBUGGER: Connected.
# A tab is closed here
DEBUGGER: ReaderThreadError: Unsupported: 8
["/Users/s15236/workspace/debug/lib/debug/server_cdp.rb:61:in `extract_data'",
 "/Users/s15236/workspace/debug/lib/debug/server_cdp.rb:103:in `block in process'",
 "/Users/s15236/workspace/debug/lib/debug/server_cdp.rb:102:in `loop'",
 "/Users/s15236/workspace/debug/lib/debug/server_cdp.rb:102:in `process'",
 "/Users/s15236/workspace/debug/lib/debug/server.rb:69:in `block (3 levels) in activate'",
 "/Users/s15236/workspace/debug/lib/debug/server.rb:212:in `setup_interrupt'",
 "/Users/s15236/workspace/debug/lib/debug/server.rb:67:in `block (2 levels) in activate'",
 "/Users/s15236/workspace/debug/lib/debug/server.rb:359:in `block (2 levels) in accept'",
 "/Users/s15236/.rbenv/versions/2.6.8/lib/ruby/2.6.0/socket.rb:809:in `block (2 levels) in accept_loop'",
 "/Users/s15236/.rbenv/versions/2.6.8/lib/ruby/2.6.0/socket.rb:806:in `each'",
 "/Users/s15236/.rbenv/versions/2.6.8/lib/ruby/2.6.0/socket.rb:806:in `block in accept_loop'",
 "/Users/s15236/.rbenv/versions/2.6.8/lib/ruby/2.6.0/socket.rb:804:in `loop'",
 "/Users/s15236/.rbenv/versions/2.6.8/lib/ruby/2.6.0/socket.rb:804:in `accept_loop'",
 "/Users/s15236/workspace/debug/lib/debug/server.rb:357:in `block in accept'",
 "/Users/s15236/.rbenv/versions/2.6.8/lib/ruby/2.6.0/socket.rb:781:in `tcp_server_sockets'",
 "/Users/s15236/workspace/debug/lib/debug/server.rb:338:in `accept'",
 "/Users/s15236/workspace/debug/lib/debug/server.rb:48:in `block in activate'"]
DEBUGGER: Disconnected.

After

% exe/rdbg target2.rb --open=chrome --port 12345
DEBUGGER: Debugger can attach via TCP/IP (127.0.0.1:12345)
DEBUGGER: With Chrome browser, type the following URL in the address-bar:

   devtools://devtools/bundled/inspector.html?ws=127.0.0.1:12345

DEBUGGER: wait for debugger connection...
DEBUGGER: Connected.
# A tab is closed here
DEBUGGER: Disconnected.
DEBUGGER: wait for debugger connection...
DEBUGGER: Debugger can attach via TCP/IP (127.0.0.1:12345)
DEBUGGER: With Chrome browser, type the following URL in the address-bar:

   devtools://devtools/bundled/inspector.html?ws=127.0.0.1:12345

@ko1
Copy link
Collaborator

ko1 commented Nov 10, 2021

is it correct fix or ad-hoc fix?

@ono-max
Copy link
Member Author

ono-max commented Nov 10, 2021

I think it's the correct fix. When the opcode is 8, it means a connection is closed.

FYI: https://datatracker.ietf.org/doc/html/rfc6455#section-5.2

@ko1
Copy link
Collaborator

ko1 commented Nov 10, 2021

Ok, another point is, exiting is correct or not. For example, it is one option to continue the debuggee.

@ono-max
Copy link
Member Author

ono-max commented Nov 11, 2021

For example, it is one option to continue the debuggee.

I see. That may be useful.

In node.js, if a tab is closed, debuggee also quit. That's why I thought that finishing it is the correct way, though.

@ko1
Copy link
Collaborator

ko1 commented Nov 11, 2021

There are 3 options:

(1) exit the debuggee too
(2) continue the debuggee (same as gdb, remote rdbg, ...) -> detach
(3) back to the rdbg REPL (and wait for the input)

To debug a server process, (2) seems nice and after detaching, it is convenient if we can attach again.

@ono-max
Copy link
Member Author

ono-max commented Nov 11, 2021

All right, let me implement it. Thanks 👍

@ono-max ono-max changed the title Terminate CDP server without an error when it gets a connection close Restart CDP server when it gets a connection close Nov 15, 2021
@ono-max
Copy link
Member Author

ono-max commented Nov 15, 2021

Updated.
@ko1 san, could you check this one?

lib/debug/server_cdp.rb Outdated Show resolved Hide resolved
@ono-max ono-max changed the title Restart CDP server when it gets a connection close Continue the debuggee after detaching to Chrome Nov 16, 2021
@ono-max ono-max requested a review from ko1 November 16, 2021 11:09
@ko1 ko1 merged commit be5214e into ruby:master Nov 25, 2021
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants