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

Breakpoint jumps due to line breaks #51698

Closed
corey-aloia opened this issue Jun 12, 2018 · 10 comments
Closed

Breakpoint jumps due to line breaks #51698

corey-aloia opened this issue Jun 12, 2018 · 10 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug debug Debug viewlet, configurations, breakpoints, adapter issues

Comments

@corey-aloia
Copy link

corey-aloia commented Jun 12, 2018

  • VSCode Version: May 2018 (version 1.24)
  • OS Version: macOs High Sierra 10.13.4

Steps to Reproduce:

  1. Using node + jest, have a line with a break similar to:
expect(my.function.with.long.path)
      .toHaveBeenCalledWith(param1, param2, param3, param4);
  1. set a breakpoint somewhere after this line
  2. observe that when starting in debug mode, the breakpoint will jump n lines, where n is the number of line breaks before said breakpoint. In this example, it will jump 1 line.
  3. remove line break. I.E.
expect(my.function.with.long.path).toHaveBeenCalledWith(param1, param2, param3, param4);
  1. observe that the breakpoint will no longer jump.

I have tested the above multiple times on 2 different macs, and you can count the line breaks and predict where the breakpoint will jump to. When I say jump, the actual line number for the breakpoint will increase. I.E. a breakpoint at myfile:37 will increase every time you click on debug by the amount of line breaks present in the file before the breakpoint.

Let me know if anymore information is needed!

Here is my launch config:

{
    "version": "0.2.0",
    "configurations": [
      {
        "name": "Debug Jest Tests",
        "type": "node",
        "request": "launch",
        "program": "${workspaceFolder}/node_modules/.bin/jest",
        "args": ["--runInBand"],
        "console": "integratedTerminal",
        "internalConsoleOptions": "neverOpen"
      }
]
}

There is no Babel or Typescript.

Vs Code is awesome by the way!

Regards,
Corey

Does this issue occur when all extensions are disabled?: Yes

@weinand weinand assigned roblourens and unassigned weinand Jun 12, 2018
@weinand weinand added the debug Debug viewlet, configurations, breakpoints, adapter issues label Jun 12, 2018
@roblourens
Copy link
Member

I can't repro this in a Jest project I have. Can you share your project? Are you sure that there are no sourcemaps or transpilation step involved?

Have you debugged this with Chrome devtools?

@roblourens roblourens added the info-needed Issue requires more information from poster label Jun 13, 2018
@corey-aloia
Copy link
Author

Hi @roblourens, thanks for the quick feedback. I went ahead and created a dummy project to demo:
https://github.com/corey-aloia-sap/vscode-bug
if you set a breakpoint in the spec.js on line 9, you should see that after clicking the green play button in the debugger, the breakpoint will move to line 10. Let me know if you need anything else!

Regards,
Corey

@krvikash35
Copy link

krvikash35 commented Jun 29, 2018

@corey-aloia-sap I also had this issue but it got resolved when i put "sourceMaps": false, in configuration. Just try and see if it helps you.

@corey-aloia
Copy link
Author

corey-aloia commented Jun 29, 2018

@sysleaf yes, this stops it from jumping, thanks! I had been removing the line breaks, but knowing this is super helpful!

@roblourens
Copy link
Member

I really thought I replied to this already, but I guess not, sorry. I tried the test project earlier and saw that the file at runtime was transpiled or transformed and linebreaks were removed. Sourcemaps should cover this but they were incorrect or missing.

@corey-aloia
Copy link
Author

@roblourens I just had a look at the vscode documentation, and it sounds like in this case the breakpoints should be showing up as gray and not hitting, but in my case they are red:

If no source map exists for the original source or if the source map is broken and cannot successfully map between the source and the generated JavaScript, then breakpoints show up as unverified (gray hollow circles)

Or am I misinterpreting this?

Thanks!

@roblourens
Copy link
Member

On second thought, this is a bug. There's still something wrong with this case when the generated file has the same name as the source file.

@roblourens roblourens added bug Issue identified by VS Code Team member as probable bug and removed info-needed Issue requires more information from poster labels Jun 29, 2018
@corey-aloia
Copy link
Author

@roblourens setting sourceMaps to false did not fully resolve this as I had initially said. Instead, it lead to it jumping under other scenarios. I.E. it fixed the one test case I presented in my demo project, but I have since run into more. I have added two more demo scenarios that can be viewed in the readme. Maybe this is a problem with the way Node is interacting with files that have line breaks and empty spaces. Either way, something doesn't seem right.

Thanks again!

@roblourens
Copy link
Member

I wouldn't expect that to fix it. That option just tells the adapter to ignore the sourcemaps which is definitely not the right thing to do.

@roblourens
Copy link
Member

Merging this into #60187 as I believe it's the same bug

@vscodebot vscodebot bot locked and limited conversation to collaborators Dec 28, 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
Projects
None yet
Development

No branches or pull requests

4 participants