镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

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

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');
}

Activity

  1. added
    inspectorIssues and PRs related to the V8 inspector protocol.
    on Feb 27, 2017
  2. mscdex commented on Feb 27, 2017

    @mscdex
    Contributor

    /cc @nodejs/v8-inspector

  3. eugeneo commented on Feb 28, 2017

    @eugeneo
    Contributor

    I have a fix for this, but it is on top of #11431 - let me refactor it to a standalone one.

  4. self-assigned this
    on Feb 28, 2017
  5. mbraude commented on Jun 20, 2017

    @mbraude

    Hello @eugeneo, this appears to have regressed in Node 8.1.2 and 9.x. Who can take a look? Our Visual Studio tooling no longer works as a result. @digeff can help get a repro or logs if the one above doesn't work.

  6. refack commented on Jun 20, 2017

    @refack
    Contributor

    @mbraude I can't repro with 8.1.2. How do I change the node executable, that is used?
    /cc @digeff

  7. eugeneo commented on Jun 20, 2017

    @eugeneo
    Contributor

    I see some odd behavior with 8.1.2 - breakpoint works inside the function but not if I put at the callsite. Stack looks fine. Might be something in V8, I am investigating.

    This may be different from what VS Code hit.

  8. refack commented on Jun 20, 2017

    @refack
    Contributor

    2017-06-20-vscode

  9. eugeneo commented on Jun 20, 2017

    @eugeneo
    Contributor

    I reproduced this in Chrome so it seems to be an issue in the V8. I opened Chrome bug https://bugs.chromium.org/p/chromium/issues/detail?id=735091 - please let me know if this looks similar to what you are seeing in VS code.

  10. nicothed commented on Oct 3, 2018

    @nicothed

    This issue just started appearing this week (or last?). Maybe after a VS Code upgrade?
    Am I the only one? How can I know where the issue is?

  11. alexkozy commented on Oct 3, 2018

    @alexkozy
    Member

    I tried to reproduce this issue with dedicated frontend from current stable Chrome, from latest dev Chrome and using ndb with node 8.11 and node 10.11. It looks like it works. Could you provide repro steps?

  12. nicothed commented on Oct 3, 2018

    @nicothed

    Oho, so you think I should install ndb? I use node 10.5.0.
    I hate to say that but it happens every time. I would say that it started about 2 weeks ago, about when I upgraded to the August version of VS Code. But that's also when I started using async/await functions. I don't think I installed new modules or anything else significant.

    While I'm at it (I know it's unrelated), are there ways to edit code while debugging, and run the updated code without restarting the app? WebStorm managed to do it, but I'm unsure if VS Code can.

  13. roblourens commented on Oct 3, 2018

    @roblourens

    @nicothed you are probably having an issue with debugging in VS Code, not node. If you file an issue on the vscode repo with more details, I can try to help you.

  14. jblazevicClover commented on May 28, 2019

    @jblazevicClover

    i deleted node_modules folder and package-lock.json, and do npm install. After that my debugger works like a charm for node and for chrome (breakpoints work)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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