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

Typescript pack debugger ECONNREFUSED #477

Closed
FiNEk opened this issue Jul 24, 2023 · 9 comments
Closed

Typescript pack debugger ECONNREFUSED #477

FiNEk opened this issue Jul 24, 2023 · 9 comments

Comments

@FiNEk
Copy link

FiNEk commented Jul 24, 2023

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

@FiNEk FiNEk changed the title Typescript pack Typescript pack debugger Jul 24, 2023
@FiNEk FiNEk changed the title Typescript pack debugger Typescript pack debugger ECONNREFUSED Jul 24, 2023
@Uzaaft
Copy link
Member

Uzaaft commented Jul 24, 2023

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

@FiNEk
Copy link
Author

FiNEk commented Jul 24, 2023

@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
Copy link
Member

Uzaaft commented Jul 24, 2023

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

@Uzaaft
Copy link
Member

Uzaaft commented Jul 25, 2023

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

@Uzaaft Uzaaft closed this as not planned Won't fix, can't repro, duplicate, stale Jul 25, 2023
@FiNEk
Copy link
Author

FiNEk commented Jul 25, 2023

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
Copy link
Member

Uzaaft commented Jul 26, 2023

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
Copy link
Author

FiNEk commented Jul 26, 2023

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
Copy link
Member

Uzaaft commented Jul 26, 2023

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

@FiNEk
Copy link
Author

FiNEk commented Jul 26, 2023

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.

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

No branches or pull requests

2 participants