mxsdev / nvim-dap-vscode-js

nvim-dap adapter for vscode-js-debug
276 stars 30 forks source link

How to open debugger terminal? #53

Open noahbald opened 1 year ago

noahbald commented 1 year ago

I'd like to be able to open a debugger terminal similar to how is done in vscode, so that I can try debugging npm or node scripts from a terminal. However, I'm struggling to digest how to set up this configuration based on the configurations given.

image

I've tried to set up my configuration as follows, with the node-terminal configured. However, when I select this option is seems to briefly open some buffers before immediately closing them.

    -- using lazy
    {
        "mxsdev/nvim-dap-vscode-js",
        config = function()
            local utils = require("dap-vscode-js.utils")
            require("dap-vscode-js").setup {
                adapters = { 'pwa-node', 'pwa-chrome', 'pwa-msedge', 'node-terminal', 'pwa-extensionHost' },
                debugger_path = utils.join_paths(utils.get_runtime_dir(), "lazy/vscode-js-debug"),
            }
            require("custom.configs.nvim-dap-vscode-js")
        end,
        dependencies = {
            "mfussenegger/nvim-dap",
            "rcarriga/nvim-dap-ui",
            {
                "microsoft/vscode-js-debug",
                build = "npm install --legacy-peer-deps && npx gulp vsDebugServerBundle && mv dist out",
            }
        },
        ft = "javascript",
    },
-- custom/configs/nvim-dap-vscode-js.lua
for _, language in ipairs({ "typescript", "javascript" }) do
    require("dap").configurations[language] = {
        {
            type = "pwa-node",
            request = "launch",
            name = "Launch file",
            program = "${file}",
            cwd = "${workspaceFolder}",
        },
        {
            type = "pwa-node",
            request = "launch",
            name = "Attach",
            processId = require("dap.utils").pick_process,
            cwd = "${workspaceFolder}",
        },
        {
            type = "node-terminal",
            request = "launch",
            name = "Launch terminal",
            cwd = "${workspaceFolder}",
        }
    }
end
Hugobsb commented 1 year ago

Hello! Have you checked out nvim-dap-ui?

noahbald commented 1 year ago

Hey @Hugobsb - I am using nvim-dap-ui, however when launching node-terminal the ui seems to immediately close the ui

Hugobsb commented 1 year ago

Oh, that can be seen in your dependencies list, my bad. It was too late here and I was sleepy haha

My guess is that there are a problem with the nvim-dap session. Have you tried to use the command: :require'dap'.set_log_level'DEBUG' to have more information on this issue? (you can set this up via lua file too)

I'm not sure where the logs will be there, but here in my Ubuntu it was at:

Does that make sense?

Although I'm not a contributor, I hope I can help before someone gets here.

noahbald commented 1 year ago

Thanks Hugo. I didn't see any logs for dap_vscode_js.log, but here is dap.log


[ INFO ] 2023-07-26T09:38:42Z+1000 ] ...dwin/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:733 ]  "Telemetry" "js-debug/launch"
[ INFO ] 2023-07-26T09:38:47Z+1000 ] ...dwin/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:733 ]  "Telemetry" "js-debug/dap/operation"
[ INFO ] 2023-07-26T09:38:48Z+1000 ] ...dwin/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:733 ]  "Telemetry" "js-debug/cdp/operation"
[ INFO ] 2023-07-26T09:38:49Z+1000 ] ...dwin/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:733 ]  "Telemetry" "js-debug/dap/operation"
[ INFO ] 2023-07-26T09:39:03Z+1000 ] ...dwin/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:733 ]  "Telemetry" "js-debug/dap/operation"
[ INFO ] 2023-07-26T09:39:03Z+1000 ] ...dwin/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:733 ]  "Telemetry" "js-debug/cdp/operation"
[ INFO ] 2023-07-26T09:39:28Z+1000 ] ...dwin/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:733 ]  "Telemetry" "js-debug/cdp/operation"
[ INFO ] 2023-07-26T09:39:28Z+1000 ] ...dwin/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:733 ]  "Telemetry" "js-debug/dap/operation"
[ INFO ] 2023-07-26T09:39:38Z+1000 ] ...dwin/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:733 ]  "Telemetry" "js-debug/cdp/operation"
[ INFO ] 2023-07-26T09:39:38Z+1000 ] ...dwin/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:733 ]  "Telemetry" "js-debug/dap/operation"
[ INFO ] 2023-07-26T09:39:43Z+1000 ] ...dwin/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:733 ]  "Telemetry" "js-debug/cdp/operation"
[ INFO ] 2023-07-26T09:39:43Z+1000 ] ...dwin/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:733 ]  "Telemetry" "js-debug/dap/operation"
[ INFO ] 2023-07-26T09:40:25Z+1000 ] ...dwin/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:733 ]  "Telemetry" "js-debug/cdp/operation"
[ INFO ] 2023-07-26T09:40:25Z+1000 ] ...dwin/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:733 ]  "Telemetry" "js-debug/dap/operation"
[ INFO ] 2023-07-26T09:41:06Z+1000 ] ...dwin/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:733 ]  "Telemetry" "js-debug/cdp/operation"
[ INFO ] 2023-07-26T09:41:06Z+1000 ] ...dwin/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:733 ]  "Telemetry" "js-debug/dap/operation"
[ INFO ] 2023-07-26T09:41:11Z+1000 ] ...dwin/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:733 ]  "Telemetry" "js-debug/cdp/operation"
[ INFO ] 2023-07-26T09:41:11Z+1000 ] ...dwin/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:733 ]  "Telemetry" "js-debug/dap/operation"
[ INFO ] 2023-07-26T09:41:28Z+1000 ] ...dwin/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:733 ]  "Telemetry" "js-debug/cdp/operation"
[ INFO ] 2023-07-26T09:41:28Z+1000 ] ...dwin/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:733 ]  "Telemetry" "js-debug/dap/operation"
[ INFO ] 2023-07-26T09:41:34Z+1000 ] ...dwin/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:733 ]  "Telemetry" "js-debug/dap/operation"
[ INFO ] 2023-07-26T09:41:34Z+1000 ] ...dwin/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:733 ]  "Telemetry" "js-debug/cdp/operation"
[ INFO ] 2023-07-26T09:41:48Z+1000 ] ...dwin/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:733 ]  "Telemetry" "js-debug/dap/operation"
[ INFO ] 2023-07-26T09:41:48Z+1000 ] ...dwin/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:733 ]  "Telemetry" "js-debug/cdp/operation"
[ INFO ] 2023-07-26T09:42:01Z+1000 ] ...dwin/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:733 ]  "Telemetry" "js-debug/cdp/operation"
[ INFO ] 2023-07-26T09:42:01Z+1000 ] ...dwin/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:733 ]  "Telemetry" "js-debug/dap/operation"
[ INFO ] 2023-07-26T09:42:12Z+1000 ] ...dwin/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:733 ]  "Telemetry" "js-debug/cdp/operation"
[ ERROR ] 2023-07-26T09:42:16Z+1000 ] ...dwin/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:947 ] "No callback found. Did the debug adapter send duplicate responses?"    {
  body = vim.empty_dict(),
  command = "disconnect",
  request_seq = 166,
  seq = 526,
  success = true,
  type = "response"
}
[ INFO ] 2023-07-26T09:42:19Z+1000 ] ...dwin/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:1715 ] "Session closed due to disconnect"
[ INFO ] 2023-07-26T09:43:00Z+1000 ] ...dwin/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:733 ]  "Telemetry" "js-debug/launch"
[ INFO ] 2023-07-26T09:43:05Z+1000 ] ...dwin/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:733 ]  "Telemetry" "js-debug/dap/operation"
[ INFO ] 2023-07-26T09:43:06Z+1000 ] ...dwin/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:733 ]  "Telemetry" "js-debug/cdp/operation"
[ INFO ] 2023-07-26T09:43:06Z+1000 ] ...dwin/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:733 ]  "Telemetry" "js-debug/dap/operation"
[ INFO ] 2023-07-26T09:43:54Z+1000 ] ...dwin/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:733 ]  "Telemetry" "js-debug/dap/operation"
[ INFO ] 2023-07-26T09:43:54Z+1000 ] ...dwin/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:733 ]  "Telemetry" "js-debug/cdp/operation"
[ INFO ] 2023-07-26T09:44:19Z+1000 ] ...dwin/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:733 ]  "Telemetry" "js-debug/launch"
[ INFO ] 2023-07-26T09:44:33Z+1000 ] ...dwin/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:733 ]  "Telemetry" "js-debug/launch"
[ ERROR ] 2023-07-26T09:44:33Z+1000 ] ...dwin/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:947 ] "No callback found. Did the debug adapter send duplicate responses?"    {
  body = vim.empty_dict(),
  command = "setExceptionBreakpoints",
  request_seq = 3,
  seq = 7,
  success = true,
  type = "response"
}
[ INFO ] 2023-07-26T09:53:30Z+1000 ] ...dwin/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:733 ]  "Telemetry" "js-debug/launch"
[ INFO ] 2023-07-26T10:00:36Z+1000 ] ...dwin/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:733 ]  "Telemetry" "js-debug/launch"
[ INFO ] 2023-07-26T10:00:43Z+1000 ] ...dwin/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:733 ]  "Telemetry" "js-debug/launch"
[ ERROR ] 2023-07-26T10:00:43Z+1000 ] ...dwin/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:947 ] "No callback found. Did the debug adapter send duplicate responses?"    {
  body = vim.empty_dict(),
  command = "setExceptionBreakpoints",
  request_seq = 3,
  seq = 7,
  success = true,
  type = "response"
}

[ INFO ] 2023-07-26T10:13:51Z+1000 ] ...dwin/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:733 ]  "Telemetry" "js-debug/launch"
[ ERROR ] 2023-07-26T10:14:08Z+1000 ] ...dwin/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:947 ] "No callback found. Did the debug adapter send duplicate responses?"    {
  body = vim.empty_dict(),
  command = "configurationDone",
  request_seq = 3,
  seq = 6,
  success = true,
  type = "response"
}

[ INFO ] 2023-07-26T10:19:18Z+1000 ] ...dwin/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:733 ]  "Telemetry" "js-debug/launch"
[ INFO ] 2023-07-26T10:19:21Z+1000 ] ...dwin/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:733 ]  "Telemetry" "js-debug/dap/operation"

[ INFO ] 2023-07-26T10:21:56Z+1000 ] ...dwin/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:733 ]  "Telemetry" "js-debug/launch"
[ DEBUG ] 2023-07-26T10:51:40Z+1000 ] ...dwin/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:1230 ]    "Connecting to debug adapter"   {
  host = "127.0.0.1",
  id = "node-terminal",
  port = "53295",
  reverse_request_handlers = {
    attachedChildSession = <function 1>
  },
  type = "server"
}
[ DEBUG ] 2023-07-26T10:51:40Z+1000 ] ...dwin/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:1608 ]    "request"   {
  arguments = {
    adapterID = "node-terminal",
    clientId = "neovim",
    clientname = "neovim",
    columnsStartAt1 = true,
    linesStartAt1 = true,
    locale = "en_AU.UTF-8",
    pathFormat = "path",
    supportsProgressReporting = true,
    supportsRunInTerminalRequest = true,
    supportsStartDebuggingRequest = true,
    supportsVariableType = true
  },
  command = "initialize",
  seq = 0,
  type = "request"
}
[ DEBUG ] 2023-07-26T10:51:40Z+1000 ] ...dwin/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:939 ] 2   {
  body = {
    additionalModuleColumns = {},
    completionTriggerCharacters = { ".", "[", '"', "'" },
    exceptionBreakpointFilters = { {
        conditionDescription = 'error.name == "MyError"',
        default = false,
        description = "Breaks on all throw errors, even if they're caught later.",
        filter = "all",
        label = "Caught Exceptions",
        supportsCondition = true
      }, {
        conditionDescription = 'error.name == "MyError"',
        default = false,
        description = "Breaks only on errors or promise rejections that are not handled.",
        filter = "uncaught",
        label = "Uncaught Exceptions",
        supportsCondition = true
      } },
    supportTerminateDebuggee = false,
    supportedChecksumAlgorithms = {},
    supportsBreakpointLocationsRequest = true,
    supportsClipboardContext = true,
    supportsCompletionsRequest = true,
    supportsConditionalBreakpoints = true,
    supportsConfigurationDoneRequest = true,
    supportsDebuggerProperties = false,
    supportsDelayedStackTraceLoading = true,
    supportsEvaluateForHovers = true,
    supportsEvaluationOptions = false,
    supportsExceptionFilterOptions = true,
    supportsExceptionInfoRequest = true,
    supportsExceptionOptions = false,
    supportsFunctionBreakpoints = false,
    supportsGotoTargetsRequest = false,
    supportsHitConditionalBreakpoints = true,
    supportsLoadedSourcesRequest = true,
    supportsLogPoints = true,
    supportsModulesRequest = false,
    supportsReadMemoryRequest = true,
    supportsRestartFrame = true,
    supportsRestartRequest = true,
    supportsSetExpression = true,
    supportsSetSymbolOptions = false,
    supportsSetVariable = true,
    supportsStepBack = false,
    supportsStepInTargetsRequest = true,
    supportsTerminateRequest = false,
    supportsTerminateThreadsRequest = false,
    supportsValueFormattingOptions = true,
    supportsWriteMemoryRequest = true
  },
  command = "initialize",
  request_seq = 0,
  seq = 1,
  success = true,
  type = "response"
}
[ DEBUG ] 2023-07-26T10:51:40Z+1000 ] ...dwin/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:1608 ]    "request"   {
  arguments = {
    command = "zsh",
    cwd = "/Users/nobaldwin/Projects/_libs/fx",
    name = "Launch terminal",
    request = "launch",
    type = "node-terminal"
  },
  command = "launch",
  seq = 1,
  type = "request"
}
[ DEBUG ] 2023-07-26T10:51:40Z+1000 ] ...dwin/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:939 ] 2   {
  body = vim.empty_dict(),
  event = "initialized",
  seq = 2,
  type = "event"
}
[ DEBUG ] 2023-07-26T10:51:40Z+1000 ] ...dwin/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:1608 ]    "request"   {
  arguments = {
    filters = {}
  },
  command = "setExceptionBreakpoints",
  seq = 2,
  type = "request"
}
[ DEBUG ] 2023-07-26T10:51:40Z+1000 ] ...dwin/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:939 ] 2   {
  body = {
    category = "telemetry",
    data = {
      adapterVersion = "1.80.0",
      nodeVersion = "v20.3.0",
      os = "darwin x64",
      parameters = '{"type":"node-terminal","name":"<string>","request":"launch","trace":false,"outputCapture":"console","timeout":10000,"timeouts":{},"showAsyncStacks":{"onceBreakpointResolved":16},"skipFiles":["<string>"],"smartStep":true,"sourceMaps":true,"sourceMapRenames":true,"pauseForSourceMap":false,"resolveSourceMapLocations":null,"outFiles":["<string>"],"sourceMapPathOverrides":{"webpack:///./~/*":"<string>","webpack:////*":"<string>","webpack://@?:*/?:*/*":"<string>","webpack://?:*/*":"<string>","webpack:///([a-z]):/(.+)":"<string>","meteor://💻app/*":"<string>"},"enableContentValidation":true,"cascadeTerminateToConfigurations":[],"__workspaceFolder":"<string>","__breakOnConditionalError":false,"cwd":"<string>","env":{},"envFile":null,"localRoot":null,"remoteRoot":null,"autoAttachChildProcesses":true,"runtimeSourcemapPausePatterns":[],"command":"<string>"}',
      request = "launch",
      type = "node-terminal"
    },
    output = "js-debug/launch"
  },
  event = "output",
  seq = 3,
  type = "event"
}
[ DEBUG ] 2023-07-26T10:51:40Z+1000 ] ...dwin/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:939 ] 2   {
  body = {
    restart = false
  },
  event = "terminated",
  seq = 4,
  type = "event"
}
[ DEBUG ] 2023-07-26T10:51:40Z+1000 ] ...dwin/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:939 ] 2   {
  body = vim.empty_dict(),
  command = "launch",
  request_seq = 1,
  seq = 5,
  success = true,
  type = "response"
}
[ DEBUG ] 2023-07-26T10:51:40Z+1000 ] ...dwin/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:939 ] 2   {
  body = vim.empty_dict(),
  command = "setExceptionBreakpoints",
  request_seq = 2,
  seq = 6,
  success = true,
  type = "response"
}
[ INFO ] 2023-07-26T10:51:41Z+1000 ] ...dwin/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:733 ]  "Telemetry" "js-debug/launch"
[ DEBUG ] 2023-07-26T10:51:41Z+1000 ] ...dwin/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:1608 ]    "request"   {
  command = "configurationDone",
  seq = 3,
  type = "request"
}