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

Debugging with Chrome as described in Documentation does not work #3270

Closed
codepunkt opened this issue Oct 12, 2017 · 6 comments
Closed

Debugging with Chrome as described in Documentation does not work #3270

codepunkt opened this issue Oct 12, 2017 · 6 comments

Comments

@codepunkt
Copy link

Is this a bug report?

Yes.

Can you also reproduce the problem with npm 4.x?

Yes.

Which terms did you search for in User Guide?

Debugging in the Editor

Environment

[email protected]
[email protected]
[email protected]
windows 10
[email protected]
[email protected]

Steps to Reproduce

  1. create-react-app chromeDebuggingTest
  2. cd chromeDebuggingTest
  3. npm i
  4. npm run start
  5. open Visual Studio Code
  6. add a .vscode folder with a launch.json according to the a
  7. set a breakpoint in Visual Studio Code (red dot on the left of a line of source code)
  8. select the debugging Panel in Visual Studio Code, press the play/start button labeled "Chrome"
  9. see the breakpoint not being hit when the app is executed in Chrome

Expected Behavior

Breakpoint being hit in Chrome

Actual Behavior

  • breakpoint is not hit
  • breakpoint color turns grey in Visual Studio Code
  • it has something to do with sourcemaps not matching
@marcelorl
Copy link

marcelorl commented Oct 19, 2017

@codepunkt I might be looking for something like this:

https://developers.google.com/web/tools/chrome-devtools/javascript/

You must use sources tab from devtools, once in there, you can find for files (cmd + p) to debug and set breakpoints.

@codepunkt
Copy link
Author

@marcelorl Thanks for the advice! There's quite a few ways to debug my application - the one outlined in your answer is one of them. My problem is not debugging in general, but explicitly debugging in VSCode using the VSCode Chrome Debugger extension as described in the User Guide.

@auchenberg
Copy link
Contributor

@codepunkt I just followed your instructions and set a breakpoint in App.js on line 9 and my breakpoint is hit using Chrome 62. You need to refresh the page in Chrome to get have your breakpoint hit in your React render code, as it's being executed before VS Code is able to attach to Chrome. Similar to how you sometimes need to refresh after Chrome DevTools has opened.

screen shot 2017-11-03 at 10 41 00 am

I know this can be confusing, but it's a simple timing problem, as our debugger attaches after Chrome has executed the code. We are working on enabling "break-on-load" breakpoints in https://github.com/Microsoft/vscode-chrome-debug/issues/445, which will make this timing issue transparent.

(cc @gaearon)

@gaearon
Copy link
Contributor

gaearon commented Nov 3, 2017

I know this can be confusing, but it's a simple timing problem, as our debugger attaches after Chrome has executed the code. We are working on enabling "break-on-load" breakpoints in Microsoft/vscode-chrome-debug#445, which will make this timing issue transparent.

Can we also add a sentence to our docs about this?

@auchenberg
Copy link
Contributor

I've added a section about this in our README, and I don't want to replicate general FAQs into framework specific docs, but we could update the react docs to have a pointer?

@auchenberg
Copy link
Contributor

Opened here #3399

@gaearon gaearon closed this as completed Nov 3, 2017
@lock lock bot locked and limited conversation to collaborators Jan 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants