AstroNvim / astrocommunity

A community repository of common plugin specifications
GNU General Public License v3.0
1.13k stars 233 forks source link

Typescript pack debugger ECONNREFUSED #477

Closed FiNEk closed 1 year ago

FiNEk commented 1 year ago

Typescript pack got updated with DAP support, but i cant get it working. Opening debugger UI and trying to launch a debugger with F5 gives me this message [debug-adapter stdout] Debug server listening at 127.0.0.1:58449 shortly after i get a popup saying that DAP: Couldn't connect to localhost:${port}: ECONNREFUSED

my config https://github.com/FiNEk/astro_nvim

Uzaaft commented 1 year ago

The dap support added in typescript pack is for JS, per the commit message.

FiNEk commented 1 year ago

@Uzaaft Sorry, forgot to mention. For testing purposes, i created empty javascript project with npm init -y. Im trying to launch a single .js file with few lines of code. No build process involved, just pure javascript.

Uzaaft commented 1 year ago
image

works fine for me in a project created with npm init -y

Uzaaft commented 1 year ago

I'm going ahead and closing this. Based upon my testing with astronvim + astrocommunity, DAP + JS works. I've tested on macOS and Linux.

FiNEk commented 1 year ago

Just a heads up, for anyone landing here from search. I came across this issue and was able to solve it by overwriting pwa-node adapter with host = "127.0.0.1"

  {
    "mfussenegger/nvim-dap",
    opts = function()
      local dap = require("dap")
      require("dap").adapters["pwa-node"] = {
        type = "server",
        host = "127.0.0.1",
        port = "${port}",
        executable = {
          command = "node",
          args = {
            require("mason-registry").get_package("js-debug-adapter"):get_install_path()
              .. "/js-debug/src/dapDebugServer.js",
            "${port}",
          },
        },
      }
      for _, language in ipairs({ "typescript", "javascript" }) do
        if not dap.configurations[language] then
          dap.configurations[language] = {
            {
              type = "pwa-node",
              request = "launch",
              name = "Launch file",
              program = "${file}",
              cwd = "${workspaceFolder}",
            },
            {
              type = "pwa-node",
              request = "attach",
              name = "Attach",
              processId = require("dap.utils").pick_process,
              cwd = "${workspaceFolder}",
            },
          }
        end
      end
    end,
  }

its weird macOS thing where its ipv6 localhost loop somehow denies ipv4 loop. you can either change address in configuration to 127.0.0.1 or you can remove ipv6 loop from your /etc/hosts

Uzaaft commented 1 year ago

Just a heads up, for anyone landing here from search. I came across this issue and was able to solve it by overwriting pwa-node adapter with host = "127.0.0.1"

  {
    "mfussenegger/nvim-dap",
    opts = function()
      local dap = require("dap")
      require("dap").adapters["pwa-node"] = {
        type = "server",
        host = "127.0.0.1",
        port = "${port}",
        executable = {
          command = "node",
          args = {
            require("mason-registry").get_package("js-debug-adapter"):get_install_path()
              .. "/js-debug/src/dapDebugServer.js",
            "${port}",
          },
        },
      }
      for _, language in ipairs({ "typescript", "javascript" }) do
        if not dap.configurations[language] then
          dap.configurations[language] = {
            {
              type = "pwa-node",
              request = "launch",
              name = "Launch file",
              program = "${file}",
              cwd = "${workspaceFolder}",
            },
            {
              type = "pwa-node",
              request = "attach",
              name = "Attach",
              processId = require("dap.utils").pick_process,
              cwd = "${workspaceFolder}",
            },
          }
        end
      end
    end,
  }

its weird macOS thing where its ipv6 localhost loop somehow denies ipv4 loop. you can either change address in configuration to 127.0.0.1 or you can remove ipv6 loop from your /etc/hosts

I’m also on Mac. How does your default /etc/hosts look?

FiNEk commented 1 year ago

I’m also on Mac. How does your default /etc/hosts look?


##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1       localhost
255.255.255.255 broadcasthost
::1             localhost
Uzaaft commented 1 year ago

Same as me. So it caused an issue for you, but not for me? That's strange

FiNEk commented 1 year ago

I agree thats weird, but im sure its not just a single /etc/hosts file. If you really want to dig, then you should compare macOS versions, firewall rules etc etc. All im saying, this is a mac problem and its beyond neovim configuration. Case closed, solution found.