svaante / dape

Debug Adapter Protocol for Emacs
GNU General Public License v3.0
448 stars 25 forks source link

Can't map loadedSource paths on my filesystem when using js-debug-node-attach #121

Closed DamienCassou closed 1 week ago

DamienCassou commented 1 month ago

As I reported in https://github.com/microsoft/vscode-js-debug/issues/2027, I can't manage to make dape recognize the paths sent by the server which look like this:

{
  "seq": 1484,
  "type": "event",
  "event": "loadedSource",
  "body": {
    "reason": "new",
    "source": {
      "name": "/(rsc)/src/app/page.jsx",
      "path": "/(rsc)/src/app/page.jsx",
      "sourceReference": 1615416030
    }
  }
}

{
  "seq": 1503,
  "type": "event",
  "event": "loadedSource",
  "body": {
    "reason": "new",
    "source": {
      "name": "/home/cassou/myproject/src/app/webpack:/@me/country/src/app/page.jsx",
      "path": "/home/cassou/myproject/src/app/webpack:/@me/country/src/app/page.jsx",
      "sourceReference": 734626073
    }
  }
}

This particular file is in fact in /home/cassou/myproject/src/app/page.jsx.

Do you know of any way to configure dapDebugServer.js to return the proper paths? Should I instead override some methods of dape.el?

svaante commented 1 month ago

Hey, I don't know how to configure source maps and paths in vscode-js-debug but what you can try is dapes own path substitute mechanism with prefix-local and prefix-remote, it's designed to solve tramp debugging so it currently it only supports one substitution rule. (I am open for extending this functionally if it's needed)

js-debug-node-attach prefix-remote "/(rsc)/" prefix-local "/home/cassou/myproject/"
DamienCassou commented 1 month ago

Thank you for your help @svaante. Replacing "/(rsc)/" didn't but but I managed to make it work with:

js-debug-node-attach :port 9230 prefix-local "/home/cassou/Documents/myproject/" prefix-remote "/home/cassou/Documents/myproject/webpack:/@me/country/"

Do you see a way to make that simpler? Should we close the PR?

svaante commented 1 week ago

Seams like we can close the PR, would like to improve the prefix-* documentation.