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

EADDRINUSE when trying to use this with Mason #65

Open
kamoshi opened this issue Jan 28, 2024 · 3 comments
Open

EADDRINUSE when trying to use this with Mason #65

kamoshi opened this issue Jan 28, 2024 · 3 comments

Comments

@kamoshi
Copy link

kamoshi commented Jan 28, 2024

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
}
@Santiago-Aquino
Copy link

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

@kamoshi
Copy link
Author

kamoshi commented Apr 4, 2024

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,
  },

@petergi
Copy link

petergi commented Jun 19, 2024

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

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

No branches or pull requests

3 participants