nvim-dap-vscode-js icon indicating copy to clipboard operation
nvim-dap-vscode-js copied to clipboard

`EADDRINUSE` when trying to use this with Mason

Open kamoshi opened this issue 2 years ago • 4 comments

I tried to use this extension with Mason, so I passed it the path from the registry

      local mason = require 'mason-registry'
      local path = mason.get_package('js-debug-adapter'):get_install_path()

However, when trying to attach to a process I get the following error:

[dap-js] JS Debugger stderr: Error: listen EADDRINUSE: address already in use ::1:8123
    at Server.setupListenHandle [as _listen2] (node:net:1893:16)
    at listenInCluster (node:net:1941:12)
    at GetAddrInfoReqWrap.doListen [as callback] (node:net:2096:7)
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:109:8) {
  code: 'EADDRINUSE',
  errno: -98,
  syscall: 'listen',
  address: '::1',
  port: 8123
}

kamoshi avatar Jan 28 '24 11:01 kamoshi

I have the same error. were you able to solve it?

Santiago-Aquino avatar Apr 04 '24 02:04 Santiago-Aquino

I haven't been able to solve this problem, but I found a different way to install JS debugger, not via Mason. This is less than ideal, because you have to build vscode-js-debug yourself and I'm not sure if this still works

{
    'mxsdev/nvim-dap-vscode-js',
    dependencies = {
      'microsoft/vscode-js-debug',
      version = '1.x',
      build = 'npm i && npm run compile vsDebugServerBundle && mv dist out',
    },
    config = function()
      local dap = require 'dap'
      --local utils = require 'dap.utils'
      local dap_js = require 'dap-vscode-js'
      --local mason = require 'mason-registry'

      ---@diagnostic disable-next-line: missing-fields
      dap_js.setup {
        -- debugger_path = mason.get_package('js-debug-adapter'):get_install_path(),
        debugger_path = vim.fn.stdpath 'data' .. '/lazy/vscode-js-debug',
        adapters = { 'pwa-node', 'pwa-chrome', 'pwa-msedge', 'node-terminal', 'pwa-extensionHost' },
      }

      local langs = { 'javascript', 'typescript', 'svelte', 'astro' }
      for _, lang in ipairs(langs) do
        dap.configurations[lang] = {
          {
            type    = 'pwa-node',
            request = 'attach',
            name    = 'Attach debugger to existing `node --inspect` process',
            cwd     = '${workspaceFolder}',
            skipFiles = {
              '${workspaceFolder}/node_modules/**/*.js',
              '${workspaceFolder}/packages/**/node_modules/**/*.js',
              '${workspaceFolder}/packages/**/**/node_modules/**/*.js',
              '<node_internals>/**',
              'node_modules/**',
            },
            sourceMaps = true,
            resolveSourceMapLocations = {
              '${workspaceFolder}/**',
              '!**/node_modules/**',
            },
          },
        }
      end
    end,
  },

kamoshi avatar Apr 04 '24 10:04 kamoshi

Good god! I've spent hours fiddling with this. I almost gave up until I stumbled onto this... Thank you!

petergi avatar Jun 19 '24 12:06 petergi

As far as I can tell this isn't related to mason, see my comment here https://github.com/mxsdev/nvim-dap-vscode-js/issues/43#issuecomment-2292493558

I'm not sure why @kamoshi 's answer used to work but it doesn't seem to anymore - maybe they released the same bug in version = '1.x', later?

TylerBarnes avatar Aug 16 '24 00:08 TylerBarnes