ITADN

Restart request doesn't wrap config in 'arguments' field (affects Delve rebuild)

#1575Openfredrikaverpil 创建于 2025-12-29
F
fredrikaverpilcommented
## Problem It seems like the `restart` request in nvim-dap sends the configuration directly as the request body, but some debug adapters (notably Delve/dlv for Go) expect the configuration to be wrapped in an `arguments` field with additional parameters like `rebuild`. When using Delve for Go debugging, the restart request completes successfully (showing "Restarted debug adapter"), but the debuggee doesn't actually restart properly because Delve doesn't receive the expected request format. ## Current behavior In [`lua/dap.lua` line 952](https://github.com/mfussenegger/nvim-dap/blob/master/lua/dap.lua#L952), the restart request sends the config directly: ```lua lsession:request('restart', config, function(err0, _) ``` ## Expected behavior Delve expects the restart request to be formatted as (see [Delve's test](https://github.com/go-delve/delve/blob/af348314db8506470f6fe5ee51be5f81b20f19ea/service/dap/server_test.go#L6020-L6030)): ```lua { arguments = { request = "launch", mode = "test", program = "...", rebuild = true, -- triggers recompilation before restart -- ... other config fields } } ``` The `rebuild` parameter was added in [go-delve/delve#4103](https://github.com/go-delve/delve/pull/4103) to fix restart functionality. It defaults to `true` when present, but it seems like without the proper `arguments` wrapper, Delve may not process the request correctly. ## Possible solution It seems like the restart request could wrap the config in an `arguments` field: ```lua lsession:request('restart', { arguments = config }, function(err0, _) ``` Or perhaps provide a way for adapters/users to customize the restart request body format. ## Workaround Currently, we work around this by disabling `supportsRestartRequest` in the session capabilities, forcing nvim-dap to use terminate+rerun instead: ```lua require("dap").listeners.after.event_initialized["my-plugin"] = function(session) session.capabilities.supportsRestartRequest = false end ``` ## References - Delve restart issue: https://github.com/go-delve/delve/issues/4102 - Delve fix (adds rebuild param): https://github.com/go-delve/delve/pull/4103 - VS Code Go had the same issue: https://github.com/golang/vscode-go/issues/3835 - DAP spec for restart request: https://microsoft.github.io/debug-adapter-protocol/specification#Requests_Restart ## Environment - nvim-dap: latest - Delve: v1.25.2 - Neovim: 0.11+
1 条评论