vscode-react-native icon indicating copy to clipboard operation
vscode-react-native copied to clipboard

VS Code won't stop on breakpoint

Open inturbidus opened this issue 10 years ago • 10 comments

Actual Behavior

  1. Open React Native App
  2. Run Debug iOS
  3. Set a Breakpoint by clicking in the gutter
  4. Reload with CMD+R in the simulator
  5. Debugger does not stop on breakpoint

Expected Behavior

  1. I expect the debugger to stop on the breakpoint

Software versions

  • React-Native VS Code extension version: 0.1.4
  • VSCode version: 1.0
  • OS platform and version: OS X El Capitan
  • React Native version: 0.23

[vscode-react-native] Finished executing: react-native run-ios --simulator iPhone 5s [vscode-react-native] Starting debugger app worker. [vscode-react-native] Established a connection with the Proxy (Packager) to the React Native application [vscode-react-native] Debugging session started successfully.

inturbidus avatar Apr 18 '16 23:04 inturbidus

@inturbidus Where are you putting the breakpoint (JavaScript code or react-native tags)? Can you trying setting a hard-breakpoint as in: "debugger;" in some javascript code and tell us if that breakpoint gets hit?

digeff avatar Apr 18 '16 23:04 digeff

I have added several breakpoints for a test, here they are:

  configureScene(route, routeStack){
->   if(route.type == 'Modal') { 
      return Navigator.SceneConfigs.FloatFromBottom
    }
}

var NavigationBarRouteMapper = {
  LeftButton(route, navigator, index, navState) {
->    if(index > 0) {
      return (
        <TouchableHighlight
          underlayColor="transparent"
          onPress={() => { if (index > 0) { navigator.pop() } }}>
          <Text style={ styles.leftNavButtonText }>Back</Text>
        </TouchableHighlight>)
    } 
    else { return null }
  }

class AboutYou extends React.Component {
  _navigate(name,type) {
->    this.props.navigator.push(
      {
        name: 'Settings',
        passProps: {
          name: name
        },
        type: type
      }
    )
  }

inturbidus avatar Apr 18 '16 23:04 inturbidus

Can you try these two lines:

var NavigationBarRouteMapper = {
  LeftButton(route, navigator, index, navState) {
  console.log("Line where the breakpoint should be hit"); // These two lines
  debugger; // These two lines
    if(index > 0) {
      return (
        <TouchableHighlight
          underlayColor="transparent"
          onPress={() => { if (index > 0) { navigator.pop() } }}>
          <Text style={ styles.leftNavButtonText }>Back</Text>
        </TouchableHighlight>)
    } 
    else { return null }
  }

And tell me if the console line is printed on the VS Code Debug Console? And if the debugger stops at: "debugger;"?

I'm trying to figure out whether the issue is that VS Code is not properly connected to the debugger, or it's properly connected but the source mapping is not mapping the breakpoints you are setting correctly.

digeff avatar Apr 19 '16 00:04 digeff

Also, could you please shake the device or simulator and tell me if the menu that appears says: "Disable Chrome Debugging" or "Enable Chrome Debugging"?

digeff avatar Apr 19 '16 00:04 digeff

The debugger does stop on the debugger line and logs to the console.

The menu says "Disable Chrome Debugging"

inturbidus avatar Apr 19 '16 00:04 inturbidus

It might be a source mapping issue. Can you please edit the launch configuration you are currently using in the launch.json file and add < , trace: "sm" > after the < "outDir": "${workspaceRoot}/.vscode/.react" > property)? That option will print debugging information regarding source maps.

Then can you remove all existing breakpoints (There is a menu for this if you right click on the Breakpoints panel in the Debug tab). Run your application, set a single breakpoint that's currently not being hit, and try to hit it.

Then please send us all the messages printed by the "trace": "sm" option (they'll appear on a different color), so we can try to figure out what's happening?

digeff avatar Apr 19 '16 00:04 digeff

It turns out that my launch.json was missing: "sourceMaps": true, "outDir": "${workspaceRoot}/.vscode/.react",

The reason is that code reports that those params are not allowed, so I had deleted them. I put them back and the breakpoints are working.

inturbidus avatar Apr 19 '16 00:04 inturbidus

Thank you guys so much! I'm really loving this setup now that it's working!

inturbidus avatar Apr 19 '16 00:04 inturbidus

You're welcome! Please do send us any feedback/suggestions/issues you find :)

digeff avatar Apr 19 '16 00:04 digeff

my first day # learning from other comment Thanks #digeff

joseph-teb avatar Apr 02 '18 13:04 joseph-teb