Skip to content

Breakpoints can't be set by a debugger (Chrome or VS Code) while the Node program is running #11589

Closed
@digeff

Description

@digeff
  • Version: v7.6.0
  • Platform: Windows 10 64 bits Version 1607
  • Subsystem: V8

Setting breakpoints while the js-program is running doesn't seem to work from neither Chrome DevTools nor VS Code. The issue seems to be that the debugger calls node, and node receives and process the request, but doesn't sends the respond right away (which is what both debuggers expect). I tested this also against node 6.9.5 and the response is sent right away.

Chrome dev tools call:
{"id":14,"method":"Debugger.getPossibleBreakpoints","params":{"start":{"scriptId":"61","lineNumber":16,"columnNumber":0},"end":{"scriptId":"61","lineNumber":17,"columnNumber":0}}}

VS Code calls:
{ "id": 12, "method": "Debugger.setBreakpointByUrl", "params": { "urlRegex": "<my_path>\app\\.js", "lineNumber": 31, "columnNumber": 0 } }

The response seems to appear the next time that a breakpoint is hit or some console output is printed (I'm not exactly sure)

Following is the test program I used to reproduce this issue.

  1. node --inspect=9111 --debug-brk app.js
  2. Resume the debugger so the program continues running
  3. Attach from Chrome Dev-tools
  4. While the js-program is running, try to set a breakpoint
  5. Actual: The verified breakpoint marker doesn't appear Expected: The verified breakpoint marker does appear
'use strict';
console.log('Command line ' + process.argv.join(" "));
console.log('Hello world: 3');
console.log('Hello world: 4');
console.log('Hello world: 5');

var iterationIndex = 0;

function runIteration() {
   console.log('Starting iteration: Line 14');
    console.log('Iteration: #' + iterationIndex++);
    scheduleNextIteration();
    console.log('Ending iteration: Line 14');
}

function printTime(time) {
    return ("0" + time.getHours()).slice(-2) + ":" +
        ("0" + time.getMinutes()).slice(-2) + ":" +
        ("0" + time.getSeconds()).slice(-2);
}

var extraDelay = 60;
var minDelay = 10;

/*
extraDelay = 300;
minDelay = 300;
*/

function scheduleNextIteration() {
    var currentTime = new Date();
    var secondsUntilNextMinute = 60 - currentTime.getSeconds();
    if (secondsUntilNextMinute < minDelay) {
        secondsUntilNextMinute += extraDelay;
    }

    var millisecondsUntilNextIteration = secondsUntilNextMinute * 1000;

    var nextIterationTime = new Date(currentTime.getTime() + millisecondsUntilNextIteration);

    console.log("Current iteration running at: " + printTime(currentTime) + ". Next iteration scheduled in " + secondsUntilNextMinute + " secs at  " + printTime(nextIterationTime));
    setTimeout(runIteration,
        millisecondsUntilNextIteration);
}

runIteration();

function deadCode() {
    console.log('Hello world: 3');
    console.log('Hello world: 4');
    console.log('Hello world: 5');
    console.log('Hello world: 3');
    console.log('Hello world: 4');
    console.log('Hello world: 5');
}

Metadata

Metadata

Assignees

Labels

inspectorIssues and PRs related to the V8 inspector protocol

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions