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 breakpoints no longer work since 1.25 #54026

Closed
gombosg opened this issue Jul 11, 2018 · 25 comments
Closed

Typescript breakpoints no longer work since 1.25 #54026

gombosg opened this issue Jul 11, 2018 · 25 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug debug Debug viewlet, configurations, breakpoints, adapter issues verified Verification succeeded
Milestone

Comments

@gombosg
Copy link

gombosg commented Jul 11, 2018

  • VSCode Version: 1.25 & 1.26 Insiders. 1.24.1 is working properly.
  • OS Version: Fedora 28 & Mac OS High Sierra (same symptoms)

Steps to Reproduce:

  1. Start our Node.js server app via launch.json or attach to a process started from the terminal.
  2. Try to set a breakpoint in the server .ts files.

Does this issue occur when all extensions are disabled?:
Yes, it's occurring with a vanilla Insiders Edition, too.

Our Typescript directory structure is the following:

  • src/... - Typescript source files
  • build/... - Built Javascript files
  • build/src/... - Source maps

E.g. src/app.ts is the main source file, build/app.js is the Javascript, build/src/app.js.map is the source map.
The Javascript files point to the source maps at their end with a relative path e.g.

//# sourceMappingURL=../src/server/app.js.map`.

The source maps are built with gulp and they point to the exact absolute source path at their end e.g.

"sourceRoot": "/home/gombosg/myApp/src"`

outFiles is properly set in launch.json, but simply attaching to a running process worked, too.

This used to work perfectly, breakpoints always worked, but they appear as 'unverified' (greyed and hollow) since 1.25. Downgrading back to 1.24.1 helped though.

Let me know if you need some special logs.

@vscodebot
Copy link

vscodebot bot commented Jul 11, 2018

(Experimental duplicate detection)
Thanks for submitting this issue. Please also check if it is already covered by an existing one, like:

@gombosg
Copy link
Author

gombosg commented Jul 11, 2018

Well, it may not be connected to VSCode itself (but e.g. a Node debug adapter component) but something that has been working so far did break on a certain VSCode version update.

@weinand weinand added the debug Debug viewlet, configurations, breakpoints, adapter issues label Jul 11, 2018
@gombosg
Copy link
Author

gombosg commented Jul 11, 2018

I made a simple test case which works in 1.24 but doesn't work in 1.25.
tsTest.zip

Instructions:

  • Run build.sh
  • Set a breakpoint in build/hello.ts
  • Run with F5, it's already configured.
  • For me it stopped at the breakpoint in 1.24, didn't stop in 1.25.

@weinand
Copy link
Contributor

weinand commented Jul 11, 2018

@gombosg does your test case work in the latest Insiders?

@gombosg
Copy link
Author

gombosg commented Jul 11, 2018

@weinand Nope. 1.25 and 1.26 Insiders seem to be affected.

@roblourens
Copy link
Member

roblourens commented Jul 11, 2018

Apparently with the mapRoot and sourceRoot tsconfig options, tsc writes out absolute local paths for sourceMappingURL and sourceRoot. I think this is wrong, they should be file URIs and are usually relative paths. I just "fixed" this last month so that / urls can be resolved from the root of a webserver. Since tsc is doing this, I'll have to support this format too. This might be too late for 1.25.1 though.

@roblourens roblourens added the bug Issue identified by VS Code Team member as probable bug label Jul 11, 2018
@roblourens
Copy link
Member

In my defense, Chrome devtools doesn't handle windows-style local paths which is what TS outputs on Windows, so I will file a bug on Typescript. It does on MacOS though.

@roblourens
Copy link
Member

I filed microsoft/TypeScript#25587

@gombosg
Copy link
Author

gombosg commented Jul 11, 2018

@roblourens Thanks a lot! Also, tsc can be configured from gulp etc. and absolute paths can be set anytime. I actually set absolutes source map paths in the gulp config file because it didn't work other way, it was trial and error. ☺️

@gombosg
Copy link
Author

gombosg commented Jul 12, 2018

FYI as a quick fix I set the source map URLs in Gulp to relative by setting a relative sourceRoot in the appropriate sourcemaps.write command. This works with 1.25 properly. (But unlike the example I attached before, it's not a native tsconfig.json solution.)

@paustint
Copy link

paustint commented Jul 12, 2018

I am also having the same issue. I was working on two typescript projects with different code-bases that have been working with breakpoints for at least the past year and both of them stopped working with the update. :(

I am not using gulp and don't plan to implement it for this issue. Any idea when this might be fixed so I can plan accordingly? (Or at least provide some workaround config I can use in my tsconfig)?

@paustint
Copy link

It appears that if I remove mapRoot from my tsconfig.json the breakpoints are properly handled and I can now debug again! :)

Here are my configs in case others experience issues to aid in possible troubleshooting.

Before

{
  "extends": "../tsconfig.json",
  "compilerOptions": {
    "declaration": false,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "lib": [
      "es7",
      "dom"
    ],
    "mapRoot": "../dist/server",
    "module": "commonjs",
    "moduleResolution": "node",
    "outDir": "../dist/server",
    "sourceMap": true,
    "strictNullChecks": false,
    "noUnusedLocals": false,
    "target": "es6",
    "typeRoots": [
      "../node_modules/@types",
      "./types"
    ]
  }
}

After

{
  "extends": "../tsconfig.json",
  "compilerOptions": {
    "declaration": false,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "lib": [
      "es7",
      "dom"
    ],
    "module": "commonjs",
    "moduleResolution": "node",
    "outDir": "../dist/server",
    "sourceMap": true,
    "strictNullChecks": false,
    "noUnusedLocals": false,
    "target": "es6",
    "typeRoots": [
      "../node_modules/@types",
      "./types"
    ]
  }
}

@roblourens
Copy link
Member

roblourens commented Jul 12, 2018

This will be fixed in TS' end in TS 3.0, but I'm trying to get a workaround out on our end in Insiders.

@paustint
Copy link

paustint commented Jul 12, 2018

I think the issue I was experiencing was actually from issue #53785 and might be unrelated from what was reported in this ticket (unless this is a duplicate)

@roblourens
Copy link
Member

@paustint Since you said it's related to mapRoot, this is probably the right issue.

@roblourens
Copy link
Member

roblourens commented Jul 13, 2018

Please try this workaround for mac/linux. Add this to your launch config:

"pathMapping": {
    "/": "/"
}

You will get an warning that the property is "not allowed", ignore it.

@noambonnie
Copy link

@gombosg Life saver! changed path to relative in gulp and I have my breakpoints again. Thank you!

@jamietre
Copy link

jamietre commented Jul 16, 2018

Also having this problem - adding pathMapping has no effect for me (having this problem on mac). I'm not using gulp, though. Latest insiders doesn't work either. I'm running Jest tests using ts-jest and no breakpoints work since updating to 1.25.1 today. debugger also doesn't work.

@jamietre
Copy link

jamietre commented Jul 17, 2018

Never mind my comment above. This is actually a Jest problem for me. Unfortunately both vscode and Jest seem to have problems related to debugging in recent releases. For me, the latest release of vscode works with jest@22 + ts-jest but not jest@23.

jestjs/jest#6683

@roblourens
Copy link
Member

There will be a fix in tomorrow's insiders build, please try it out.

@JacksonKearl
Copy link
Contributor

I wasn't able to break with:

tsconfig.json:

{
    "include": [
        "src/**/*"
    ],
    "compilerOptions": {
        "sourceMap": true,
        "sourceRoot": "src/",
        "outDir": "build/",
        "mapRoot": "build/"
    }
}

but was after removing the mapRoot and sourceRoot entries.

@JacksonKearl JacksonKearl reopened this Aug 2, 2018
@JacksonKearl JacksonKearl added verification-found Issue verification failed and removed verified Verification succeeded labels Aug 2, 2018
@roblourens
Copy link
Member

roblourens commented Aug 2, 2018

That is probably producing paths that are not correct. Also, what TS version? It's different after 3.

@JacksonKearl
Copy link
Contributor

3.0.1

@roblourens
Copy link
Member

roblourens commented Aug 2, 2018

Yeah with those options you get //# sourceMappingURL=../src/build/foo.js.map which is nonsense, mapRoot is more for when your build process is moving files around, and you need tsc to account for that, like the original repro example above.

@roblourens roblourens removed the verification-found Issue verification failed label Aug 2, 2018
@JacksonKearl JacksonKearl added the verified Verification succeeded label Aug 3, 2018
@JacksonKearl
Copy link
Contributor

Verified for TS@<3.0

@vscodebot vscodebot bot locked and limited conversation to collaborators Sep 16, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug debug Debug viewlet, configurations, breakpoints, adapter issues verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

7 participants