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

Breakpoints not mapping correct between TS and JS files despite absolute or relative sourceMaps #117211

Closed
EliSchleifer opened this issue Feb 22, 2021 · 6 comments
Assignees
Labels
debug Debug viewlet, configurations, breakpoints, adapter issues *duplicate Issue identified as a duplicate of another issue(s)

Comments

@EliSchleifer
Copy link

  • VS Code Version: VS Code Insider 1.5.4
  • OS Version: Ubuntu 20.10 remote, OSX as local host

Steps to Reproduce:

  1. Using bazel to build extension in typescript.
  2. I have noted that I have correctly compiled my JS files which end up placed in a symlink path. Next to the js files is the .map files. which If I open will correctly open a symlinked ts file.
  3. I have tried placing breakpoints in the symlinked ts file that lives at a location like

extension.js
/home/eli/.cache/bazel/_bazel_eli/6ab7f98a34b740eb8432b3beaaef9fee/execroot/trunk/bazel-out/k8-fastbuild/bin/trunk/vscode/extension.js
extension.js.map
{"version":3,"file":"extension.js","sourceRoot":"","sources":["../../../../../trunk/vscode/extension.ts"],....}

  1. I have also tried with sourceMaps where I have set the sourceRoot in tsconfig to be an absolute path to avoid all the potential hiccups with a symlink
    {"version":3,"file":"extension.js","sourceRoot":"/home/eli/GitHub/trunk/","sources":["trunk/vscode/extension.ts"],"....}

  2. The basic hello world built with tsc directly with output directories directly below the source works without a problem. I can also attach debugger with debugger statement. I just want to be able to debug with the ts source code.

6 Launch .json looksl like this:
{
"name": "VS Code Extension Run",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}/trunk/vscode",
],
"sourceMaps": true,
"outFiles": [
"${workspaceFolder}/bazel-bin/trunk/vscode/**/*.js"
],
"trace": true
}

  1. Package.json looks like this:
    ....
    "main": "../../bazel-bin/trunk/vscode/extension.js",
    "contributes": {
    "commands": [
    {
    "command": "trunk.helloWorld",
    "title": "Hello World"
    },
    {
    "command": "trunk.goodbye",
    "title": "Goodbye"
    }
    ]
    },

I've attached trace log
vscode-debugadapter-a94b88df.json.gz

Yes. I disabled all installed extensions except the remote extension needed for SSH

@weinand weinand added the debug Debug viewlet, configurations, breakpoints, adapter issues label Feb 22, 2021
@connor4312
Copy link
Member

Since linked paths are resolved, I recommend setting your outFiles to point to the compiled bazel location on disk, and then also setting the sourceRoot in your tsc or tsconfig to point to the absolute path to your workspace location.

Better automatic handling may come with microsoft/vscode-js-debug#776

@connor4312 connor4312 added the *duplicate Issue identified as a duplicate of another issue(s) label Feb 22, 2021
@EliSchleifer
Copy link
Author

@connor4312 - I have already attempted both of those changes
my outFiles are set to:
"${workspaceFolder}/bazel-bin/trunk/vscode/**/*.js" - bazel-bin is is symlink to the bazel cache out directory. All the js is compiled under trunk/vscode and should be globbed correctly

My sourceRoot was set to the absolute path "/home/eli/GitHub/trunk"

Any other debugging info I can provide to narrow down. I am happy to tweak our settings, just can't get anything that works.

@connor4312
Copy link
Member

"${workspaceFolder}/bazel-bin/trunk/vscode/**/*.js" - bazel-bin is is symlink to the bazel cache out directory.

The problem is that Node will automatically resolve these symlinks, so the URL for scripts that gets reported from the runtime is, in the case of the log,

file:///home/eli/.cache/bazel/_bazel_eli/6ab7f98a34b740eb8432b3beaaef9fee/execroot/trunk/bazel-out/k8-fastbuild/bin/trunk/vscode/extension.js

...instead of the path in your working directory. The debugger doesn't know these paths are equivalent--that's part of what the linked issue covers. But I think it would work if you (can know and pass) file:///home/eli/.cache/bazel/_bazel_eli/6ab7f98a34b740eb8432b3beaaef9fee/execroot/trunk/bazel-out/k8-fastbuild/bin/**/*.js in your outfiles, instead of what you do today.

@EliSchleifer
Copy link
Author

EliSchleifer commented Feb 22, 2021 via email

@connor4312
Copy link
Member

If it's easy for you to do, a sample repo wouldn't hurt so I can make sure your use case is handled.

@github-actions github-actions bot locked and limited conversation to collaborators Apr 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
debug Debug viewlet, configurations, breakpoints, adapter issues *duplicate Issue identified as a duplicate of another issue(s)
Projects
None yet
Development

No branches or pull requests

4 participants
@EliSchleifer @weinand @connor4312 and others