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

Workaround for empty setBreakpoints response #116

Closed
wants to merge 1 commit into from

Conversation

mfussenegger
Copy link
Owner

@mfussenegger mfussenegger commented Mar 3, 2021

Looks like delve can send a response that is nil:

.config/nvim/pack/plugins/start/nvim-dap/lua/dap.lua:760: attempt to index local 'resp' (a nil value)

This is with the following adapter config:

  dap.adapters.go = {
    type = 'server',
    host = '127.0.0.1',
    port = 46545
  }
recording.mp4

@theHamsta
Copy link
Contributor

Yeah, I changed this also sometimes but was not sure whether I was doing something wrong. Probably good to check from this case.

Looks like some adapters don't send a body in the setBreakpoints
response. This caused the initialization to fail.

```
nvim-dap/lua/dap.lua:760: attempt to index local 'resp' (a nil value)
```
@mfussenegger
Copy link
Owner Author

I'm actually not sure what is really going on.

From the log it looks like the response is sent twice:

[ DEBUG ] 2021-03-03T22:47:38Z+0100 ] ...rdi/.config/nvim/pack/plugins/start/nvim-dap/lua/dap.lua:837 ]	{
  body = {
    breakpoints = { {
        line = 7,
        source = {},
        verified = true
      } }
  },
  command = "setBreakpoints",
  request_seq = 1,
  seq = 0,
  success = true,
  type = "response"
}
[ WARN ] 2021-03-03T22:47:38Z+0100 ] ...rdi/.config/nvim/pack/plugins/start/nvim-dap/lua/dap.lua:842 ]	"No callback for "	{
  body = {
    breakpoints = { {
        line = 7,
        source = {},
        verified = true
      } }
  },
  command = "setBreakpoints",
  request_seq = 1,
  seq = 0,
  success = true,
  type = "response"
}

The first clears the callback, so the second time there is the No callback for warning.
What I don't get is that although there is a body in the log, it somewhere goes missing.

An assertion like this:

nvim-dap/lua/dap.lua

Lines 847 to 848 in 7dc11c3

if decoded.success then
assert(decoded.body, 'There must be a body in a successful response')

Triggers an error.

@mfussenegger
Copy link
Owner Author

mfussenegger commented Mar 3, 2021

Looks like the root cause of the issue is that seq is not being increased in delve, and nvim-dap currently relies on that to set the request_seq numbers.

The setBreakpoints response isn't sent twice, that was just the duplicate logging that confused me. But the launch and setBreakpoints have the same request_seq:

[ DEBUG ] 2021-03-03T23:08:14Z+0100 ] ...rdi/.config/nvim/pack/plugins/start/nvim-dap/lua/dap.lua:837 ]	{
  command = "launch",
  request_seq = 1,
  seq = 0,
  success = true,
  type = "response"
}
[ DEBUG ] 2021-03-03T23:08:14Z+0100 ] ...rdi/.config/nvim/pack/plugins/start/nvim-dap/lua/dap.lua:837 ]	{
  body = {
    breakpoints = { {
        line = 7,
        source = {},
        verified = true
      } }
  },
  command = "setBreakpoints",
  request_seq = 1,
  seq = 0,
  success = true,
  type = "response"
}

Given that this sequence numbering issue can lead to other problems I'm not sure if the PR here should be merged as is.

See go-delve/delve#2245 for a bug report

@mfussenegger
Copy link
Owner Author

#117 is the proper fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants