svaante / dape

Debug Adapter Protocol for Emacs
GNU General Public License v3.0
467 stars 28 forks source link

Timeout for Regal debugger #153

Open hochata opened 2 weeks ago

hochata commented 2 weeks ago

Hi! Thanks for this package, it is incredible!

I tried to get Regal debugger to work but I can't get past the initialization. The debugger is not very documented so I apologize if the error is not with Dape.

Sample code file

package rules.examples

import rego.v1

id := "basic_rule"

Dape config

M-x dape RET launch command-cwd dape-cwd command "regal" command-args ("debug" "--verbose") :type "opa-debug" :command "eval" :query "id"

Events buffer

[jsonrpc] e[20:10:05.392] --> initialize[1] {"type":"request","seq":1,"command":"initialize","arguments":{"clientID":"dape","adapterID":"opa-debug","pathFormat":"path","linesStartAt1":true,"columnsStartAt1":true,"supportsRunInTerminalRequest":true,"supportsProgressReporting":true,"supportsStartDebuggingRequest":true}}
[jsonrpc] i[20:10:15.398] [1] timed-out request 'initialize'
[jsonrpc] e[20:10:15.400] --> disconnect[2] {"type":"request","seq":2,"command":"disconnect","arguments":{"restart":false}}
[jsonrpc] D[20:10:15.410] Connection state change: `finished
'

----------b---y---e---b---y---e----------

Connection output

time="2024-09-23T20:10:05-06:00" level=debug msg="Waiting for message..."
time="2024-09-23T20:10:05-06:00" level=debug msg="Received *dap.InitializeRequest\n{\"seq\":1,\"type\":\"request\",\"command\":\"initialize\",\"arguments\":{\"clientID\":\"dape\",\"adapterID\":\"opa-debug\",\"linesStartAt1\":true,\"columnsStartAt1\":true,\"pathFormat\":\"path\",\"supportsRunInTerminalRequest\":true,\"supportsProgressReporting\":true,\"supportsStartDebuggingRequest\":true}}"
time="2024-09-23T20:10:05-06:00" level=info msg="Initializing: {\"clientID\":\"dape\",\"adapterID\":\"opa-debug\",\"linesStartAt1\":true,\"columnsStartAt1\":true,\"pathFormat\":\"path\",\"supportsRunInTerminalRequest\":true,\"supportsProgressReporting\":true,\"supportsStartDebuggingRequest\":true}"
time="2024-09-23T20:10:05-06:00" level=debug msg="Waiting for message..."
time="2024-09-23T20:10:05-06:00" level=debug msg="Sending *dap.InitializeResponse\n{\"seq\":1,\"type\":\"response\",\"request_seq\":1,\"success\":true,\"command\":\"initialize\",\"body\":{\"supportsConfigurationDoneRequest\":true,\"supportTerminateDebuggee\":true,\"supportSuspendDebuggee\":true,\"supportsTerminateRequest\":true,\"supportsCancelRequest\":true,\"supportsBreakpointLocationsRequest\":true,\"supportsSingleThreadExecutionRequests\":true}}"
Content-Length: 340

{"seq":1,"type":"response","request_seq":1,"success":true,"command":"initialize","body":{"supportsConfigurationDoneRequest":true,"supportTerminateDebuggee":true,"supportSuspendDebuggee":true,"supportsTerminateRequest":true,"supportsCancelRequest":true,"supportsBreakpointLocationsRequest":true,"supportsSingleThreadExecutionRequests":true}}

time="2024-09-23T20:10:15-06:00" level=debug msg="Received *dap.DisconnectRequest\n{\"seq\":2,\"type\":\"request\",\"command\":\"disconnect\",\"arguments\":{}}"

Dape repl

* Welcome to Dape REPL! *
Available Dape commands: debug, next, continue, pause, step, out, up, down, restart, kill, disconnect, quit
Empty input will rerun last command.

* Adapter started with "regal debug --verbose" *
* Command initialize timed out after 10 seconds, the timeout period is configurable with `dape-request-timeout' *
Initialize failed due to: Request timeout
* Adapter connection shutdown without successfully initializing *
Configuration:
  modes nil
  command-cwd "<project/root>"
  ensure (lambda (config) (unless (plist-get config 'command) (user-error "Missing `command' property")))
  :request "launch"
  command "regal"
  command-args ("debug" "--verbose")
  :type "opa-debug"
  :command "eval"
  :query "id"
time="2024-09-23T20:10:05-06:00" level=debug msg="Waiting for message..."
time="2024-09-23T20:10:05-06:00" level=debug msg="Received *dap.InitializeRequest\n{\"seq\":1,\"type\":\"request\",\"command\":\"initialize\",\"arguments\":{\"clientID\":\"dape\",\"adapterID\":\"opa-debug\",\"linesStartAt1\":true,\"columnsStartAt1\":true,\"pathFormat\":\"path\",\"supportsRunInTerminalRequest\":true,\"supportsProgressReporting\":true,\"supportsStartDebuggingRequest\":true}}"
time="2024-09-23T20:10:05-06:00" level=info msg="Initializing: {\"clientID\":\"dape\",\"adapterID\":\"opa-debug\",\"linesStartAt1\":true,\"columnsStartAt1\":true,\"pathFormat\":\"path\",\"supportsRunInTerminalRequest\":true,\"supportsProgressReporting\":true,\"supportsStartDebuggingRequest\":true}"
time="2024-09-23T20:10:05-06:00" level=debug msg="Waiting for message..."
time="2024-09-23T20:10:05-06:00" level=debug msg="Sending *dap.InitializeResponse\n{\"seq\":1,\"type\":\"response\",\"request_seq\":1,\"success\":true,\"command\":\"initialize\",\"body\":{\"supportsConfigurationDoneRequest\":true,\"supportTerminateDebuggee\":true,\"supportSuspendDebuggee\":true,\"supportsTerminateRequest\":true,\"supportsCancelRequest\":true,\"supportsBreakpointLocationsRequest\":true,\"supportsSingleThreadExecutionRequests\":true}}"
Content-Length: 340

{"seq":1,"type":"response","request_seq":1,"success":true,"command":"initialize","body":{"supportsConfigurationDoneRequest":true,"supportTerminateDebuggee":true,"supportSuspendDebuggee":true,"supportsTerminateRequest":true,"supportsCancelRequest":true,"supportsBreakpointLocationsRequest":true,"supportsSingleThreadExecutionRequests":true}}

time="2024-09-23T20:10:15-06:00" level=debug msg="Received *dap.DisconnectRequest\n{\"seq\":2,\"type\":\"request\",\"command\":\"disconnect\",\"arguments\":{}}"
> 

So I think the server is returning the initialization response, but for some reason Dape doesn't received it, and the connection times out. Any help is welcomed!

svaante commented 2 weeks ago

Hey! I got the following "working", seams like regals stdout com breaks jsonrpc parsing.

(add-to-list 'dape-configs
             '(regal
               command "regal"
               command-args ("debug" "--server" "--address" "127.0.0.1::autoport")
               port :autoport
               :bundlePaths (lambda () (vector (dape-command-cwd)))
               :command "eval"
               :query "data"
               :stopOnEntry t
               :stopOnFail t
               :stopOnResult t
               :enablePrint t))

As I am not familiar with regal so I can't verify how well it works :)

hochata commented 2 weeks ago

It works perfectly! Thanks a lot.

How exactly does regal break the parsing? I'll try to report it upstream.

svaante commented 1 week ago

I am not really sure, but I would guess that is hat something with it echoing out received message as follows:

time="2024-09-28T13:02:54+02:00" level=info msg="Initializing: {\"clientID\":\"dape\",\"adapterID\":\"\",\"linesStartAt1\":true,\"columnsStartAt1\":true,\"pathFormat\":\"path\",\"supportsRunInTerminalRequest\":true,\"supportsProgressReporting\":true,\"supportsStartDebuggingRequest\":true}"
Content-Length: 340

{"seq":1,"type":"response","request_seq":1,"success":true,"command":"initialize","body":{"supportsConfigurationDoneRequest":true,"supportTerminateDebuggee":true,"supportSuspendDebuggee":true,"supportsTerminateRequest":true,"supportsCancelRequest":true,"supportsBreakpointLocationsRequest":true,"supportsSingleThreadExecutionRequests":true}}