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 map to wrong line in chrome #51

Closed
nioufe opened this issue Mar 2, 2016 · 11 comments
Closed

Breakpoints map to wrong line in chrome #51

nioufe opened this issue Mar 2, 2016 · 11 comments
Labels
bug needs reproduction This issue is missing a minimal runnable reproduction, provided by the author

Comments

@nioufe
Copy link

nioufe commented Mar 2, 2016

Hello,
I've been trying to get my breakpoints in chrome to show the proper line while debugging an app generated with vue-cli. Usually the problem I have is : The breakpoint stops execution properly but my app really is 2 lines up or down.

An example :
var a = 1;
a++; <-- breakpoint
a++;
When chrome stops execution, a is either 1 or 3 instead of 2.

I figured the problem should come from webpack, and found that changing :
config.devtool = 'eval-source-map' to config.devtool = 'source-map' solves the issue. (And also has easier names for files when debugging).

I tried to understand how the change solved the issue but no luck there... I'm still a beginner with webpack.

@yyx990803
Copy link
Member

Is the code inside a *.vue file?

@nioufe
Copy link
Author

nioufe commented Mar 3, 2016

Yes.
But I also tried :
Code inside a js file required in main.js
Code inside a js file include in a < script src="" > of a vue file

I'm (almost) sure all of them had the issue.

@nioufe
Copy link
Author

nioufe commented Mar 3, 2016

Node and npm version - npm: '2.14.7', node: '4.2.3'
Chrome 48.0.2564
And I believe Firefox had the issue too.

@skyronic
Copy link
Collaborator

Do you have hot reloading enabled? I was also experiencing this issue where the source maps were not in sync with the code, and sometimes even though chrome would break on the right line, it would sometimes not match up in the sources view.

I will investigate whether this is a webpack issue or a chrome issue. But either way I am not sure if this is vuejs or vue-cli specific

@azamat-sharapov
Copy link

I tried to understand how the change solved the issue but no luck there

Have a look at the table from this documentation, specifically "quality" column.
"original source" means sourcemaps will point to original source files, so when you set breakpoint to original file, you may not have luck pausing runtime.
Try to change devtool to "eval" and check how breakpoints work.

@chrisvfritz
Copy link
Contributor

@nioufe @skyronic Any luck resolving this? Was @azamat-sharapov's suggestion helpful?

@nioufe
Copy link
Author

nioufe commented Apr 5, 2016

@azamat-sharapov Changing from "eval-source-map" to "source-map" solved the issue.
So breakpoints do work in the original files under some conditions.

I'll try "eval" to see how it works. Hopefully i'll come back with better answers.

@skyronic I agree, this doesn't look like a vue-cli issue, maybe vue-loader? I'm not familiar with how it works =/
But if there is a default configuration that works better than the current one, maybe you could consider changing the value of "devtool" ?

@chrisvfritz
Copy link
Contributor

@nioufe Any further word?

@chrisvfritz chrisvfritz added the needs reproduction This issue is missing a minimal runnable reproduction, provided by the author label Apr 22, 2016
@nioufe
Copy link
Author

nioufe commented May 21, 2016

I'm still trying (from time to time) to find where this is coming from.

With "#eval-source-map", breakpoints are broken across browsers. I tried with vue-cli/vue-loader latest versions and only random breakpoints work. Most of the time they don't get triggered.

With "#source-map", only breakpoints in the first lines of a file seem to be broken. I found a Babel 6 issue which could explain this : https://phabricator.babeljs.io/T7210

Maybe this is two different issues. I'm starting to learn how webpack/vue-loader/babel interact to try to pinpoint exactly which one is guilty.

@chrisvfritz
Copy link
Contributor

@nioufe Thanks for your continued research into this! It sounds like you're zeroing in on it. 🙂

@zigomir
Copy link
Contributor

zigomir commented Sep 11, 2016

Closing due to inactivity, please open new issue if there's more information available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug needs reproduction This issue is missing a minimal runnable reproduction, provided by the author
Projects
None yet
Development

No branches or pull requests

6 participants