Vscode: VSCode restart debugging not working anymore

Created on 27 Dec 2019  路  42Comments  路  Source: microsoft/vscode

I'm using VSCode debugging to debug Node.js application. Whenever I try to restart the debugging after making changes in the code it terminates the debugging.

I get this error in the logs:

[2019-12-27 16:23:07.775] [renderer1] [error] timeout after 500 ms: Error: timeout after 500 ms
    at t.RawDebugSession.handleErrorResponse (file:///C:/Users/neosoft_sushantk/AppData/Local/Programs/Microsoft VS Code/resources/app/out/vs/workbench/workbench.desktop.main.js:2821:819)
    at file:///C:/Users/neosoft_sushantk/AppData/Local/Programs/Microsoft VS Code/resources/app/out/vs/workbench/workbench.desktop.main.js:2821:250
    at async t.RawDebugSession.shutdown (file:///C:/Users/neosoft_sushantk/AppData/Local/Programs/Microsoft VS Code/resources/app/out/vs/workbench/workbench.desktop.main.js:2819:336)
    at async R.terminate (file:///C:/Users/neosoft_sushantk/AppData/Local/Programs/Microsoft VS Code/resources/app/out/vs/workbench/workbench.desktop.main.js:5113:637)
    at async Y.restartSession (file:///C:/Users/neosoft_sushantk/AppData/Local/Programs/Microsoft VS Code/resources/app/out/vs/workbench/workbench.desktop.main.js:5138:397)
bug debug verified

Most helpful comment

I am having the same problem since 2-3 weeks ago. Restart button just end the debug session. But thanks to this comment, double click solve the problem. Double click on restart button restart debug session. It used to be single click tho.

All 42 comments

This has been mentioned in https://github.com/microsoft/vscode/issues/85386 and https://github.com/microsoft/vscode/issues/86800

I get the same error. Disabling all extensions makes the problem go away, and if I only enable Python extension (since my project is in Python), and try to run it there, I get the same error message.

This has been mentioned in #85386 and #86800

I get the same error. Disabling all extensions makes the problem go away, and if I only enable Python extension (since my project is in Python), and try to run it there, I get the same error message.

@elahmo Did you try reinstalling vscode?

@SushKenyNeosoft yes I have, doesn't seem to have an effect.

It's really annoying to stop and start the debugging just for restarting

For me as well. I know it sounds like _a first world problem_, two clicks instead of one, but using this for years makes it really hard to forget and there is so many times I click restart and just wait, try to open something and figure out it has not been relaunched.

I am trying with the keyboard shortcuts, but with modifier keys on Mac it is quite awkward of a combination to stop-start.

Have you considered to use "nodemon"?
With nodemon your app is restarted automatically when a source change is detected and VS Code will start the debug session automatically as well.
So "zero clicks" instead of one or two...

For me it would not be a desireable solution as the project is a rather large Django application, so the reloading takes a bit of time, and having it done every time on a file save could be counterproductive.

Nodemon can be configured to cope with that: https://github.com/remy/nodemon#delaying-restarting
BTW, nodemon is not confined to node.js. It can be used with python as well: https://github.com/remy/nodemon#running-non-node-scripts

It's not an option for me either, I'm using a framework for microservices named moleculer which has it's own building mechanism.

Here's the launch.json file:

{
    // Use IntelliSense to learn about possible Node.js debug attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "launch",
            "name": "Debug",
            "program": "${workspaceRoot}/node_modules/moleculer/bin/moleculer-runner.js",
            "cwd": "${workspaceRoot}",
            "args": [
                "services"
            ]
        },
        {
            "type": "node",
            "request": "launch",
            "name": "Jest",
            "program": "${workspaceRoot}/node_modules/jest-cli/bin/jest.js",
            "args": ["--runInBand"],
            "cwd": "${workspaceRoot}",
            "runtimeArgs": [
                "--nolazy"
            ]
        }
    ]
}

@SushKenyNeosoft with your launch config it looks like you are debugging the building mechanism, and not your program, right?

Yes

So that means that pressing "Restart" does not restart your program but your builder, right?

Restart ends the debug session

I am having the same problem since 2-3 weeks ago. Restart button just end the debug session. But thanks to this comment, double click solve the problem. Double click on restart button restart debug session. It used to be single click tho.

@PyaePhyoKhant double click worked for me too :). Thanks sir!
@weinand but it's weird though

For me it seems to work as well, the debug session tries to start, but it appears the previous instance is not shut down, so it fails as the port is already in use.

Clicking stop doesnt kill the server either, so now in addition to manually stopping and starting, I have to see the PID of the process listening on 8000, kill it, and start then.

This is getting quite annoying, something is definitely broken as I haven't made any changes to the project or system, other than letting VSCode update regularly.

Same here, pressing restart just stops and does nothing, disabled all extensions and reinstalled visual studio code already. Seems like a simple problem to fix but has a huge annoyance factor if you are used to it, also because I use a very wide display I have to seriously pan to get to the Debug menu item since I am used that the retsrta and pause buttons appear on the right of my screen

@TijsDeBelie "seems like a simple problem to fix": agreed, but nobody on our side was able to reproduce the problem (which makes it still difficult to understand and fix the problem...)

What debugger are you using?

@weinand It's working properly in Windows 7 and Ubuntu, the problem is in Windows 10.

@SushKenyNeosoft It is strange.

  • It is working for me properly on Win 10. But it is not on Ubuntu 18.04.
  • I also tried debug with multiple languages (python, js and go) and found out that only python is having problem which is my main language. Other language debuggers js and go are working properly. It seem to me that only our commonly used language is having problem.
  • I tried rolling back vscode version but still had same problem.

@weinand I am using version 1.14.1 and node.js 12.4.0 and I am using windows 10, I haven't done any recent updates that caused it to break, only security fixes.

Debugger is the one build in for node.js

"version": "0.2.0",
"configurations": [
    {
        "type": "node",
        "request": "launch",
        "name": "Launch Program",
        "skipFiles": [
            "<node_internals>/**"
        ],
        "program": "${workspaceFolder}\\index.js"
    }
]

@SushKenyNeosoft It is strange.

  • It is working for me properly on Win 10. But it is not on Ubuntu 18.04.
  • I also tried debug with multiple languages (python, js and go) and found out that only python is having problem which is my main language. Other language debuggers js and go are working properly. It seem to me that only our commonly used language is having problem.
  • I tried rolling back vscode version but still had same problem.

Same here the only difference is I'm using Node.js

Same problem here. Cannot restart debugger anymore.
I thought it was the new Windows 10 update, because it started few days ago.
Since then I noticed the following:
1-Debugger cannot restart
2-Debugger is much slower to start.
3-Debugger is much slower to stop, takes several seconds. Before it was immediate.

I'm using Win 10, Vs Code 1.42 32 bit and debugging node js.

I changed the "Debug: Restart" shortcut to Ctrl + F5 and oddly the problem is now solved !!!

On MacOS it doesn't make a difference.

I was using my laptop for a few days which has older version and there the debugging seems super responsive, and the shortcuts work, something along with @00christian00 's notes.

This seems like a problem that is affecting not a trivial amount of people, giving that most people will not go to GitHub issues or haven't noticed it in their flow.

I also have the same problem.

OS: windows 10
language: python
vscode: version 1.42 (64 bits)

I am willing to provide the information but I am new to programming, could anyone please share with me what kind of information is necessary to provide here? Thank you

@jollyreal please create your issue with detailed steps against the Python extension.

I've just upgraded the Node JS installation to 12.15 on my Windows 10 machine and everything restarted working normally.
I don't know if it's because I upgraded to this new version or simply because the update reinstalled node js, could be both.

@weinand, thank for reply.
Now oddly return to normal.I also don't know why.

It is also back to normal for me now.

"back to normal" means: "Restart" is working fine now, correct?

@weinand
For me all is fast now, including restart.

@weinand Yup. Restart is working fine now. I wonder what fixed it.

Same goes for Python, all working well for me too.

@weinand Restart debugging in vscode insider also not working for java debugging, see https://github.com/microsoft/vscode-java-debug/issues/752. In java debug, we implement the restart feature by terminating and relaunching the adapter.

Below is the sequence I observed at java debug side:

>[request]
{"command":"disconnect","arguments":{"restart":true},"type":"request","seq":9}

<[[EVENT]]
Content-Length: 91

{"event":"terminated","body":{"restart":false,"type":"terminated"},"seq":27,"type":"event"}

>the debug connection closed by the client

<[[RESPONSE]]
Content-Length: 82

{"success":true,"request_seq":9,"command":"disconnect","seq":13,"type":"response"}

At first, i suspect it's because the java debug sends a terminate event during the disconnect request handler. Then i try to disable the terminate event or move it after disconnect response, it still doesn't work. Below is the new sequence i tried.

>[request]
{"command":"disconnect","arguments":{"restart":true},"type":"request","seq":10}

>the debug connection closed by the client

<[[RESPONSE]]
Content-Length: 83

{"success":true,"request_seq":10,"command":"disconnect","seq":12,"type":"response"}

<[[EVENT]]
Content-Length: 90

{"event":"terminated","body":{"restart":true,"type":"terminated"},"seq":13,"type":"event"}

The problem looks like the client closed the debug connection immediately after sending disconnect request. Not sure why this happens.

Ok, so tl:dr Restart does not work for Java but works for everything else?
@testforstephen and this is nicely working in stable, so you can only reproduce with vscode insiders?
Can you maybe F1 > Developer Tools > put a breakpoint here and try to see why the restart is not called.
I can also setup Java some time later this week and try to repro.

Also reproduce in stable version 1.42.1.

restartSession function can be hit, and the function seems to exit at the line await session.terminate(true);, and the breakpoint at line never be executed.

...
        if (isAutoRestart) {
            await session.disconnect(true);
        } else {
            await session.terminate(true);         <--- can be hit
        }

        return new Promise<void>((c, e) => {
            setTimeout(async () => {
                const taskResult = await runTasks();             <--- never be hit
                if (taskResult !== TaskRunResult.Success) {
                    return;
                }
...

One question here. Is there any timeout limit about the disconnect request handling?
The background is the java debug adds some step to clean up the temp files during handling the disconnect request. And considering the temp files may be occupied by the debuggee process, so the debug will retry 5 times for cleaning the temp files, the sleep interval for each retry is 1s.

@testforstephen thanks for debugging. Based on what you found it seems to happen that the terminate request does not get resolved. And currently for the disconnect we use the 500ms timeout and for terminate we use no timeout.
I have changed VS Code that we also use 500ms timeout for the terminate request. I think it makes sense that they are on par.
Please try it out with Wednesday's vscode insiders and let us know if it is better now.
If it still happens we can reopen this.

@isidorn i got the root cause for the restart failure happening in java debugging.
image

java debugger takes about more than 1s to return the disconnect response, and it causes timeout.
when i make the debugger returns disconnect response in 500ms, the issue disappears.

@testforstephen ok, so can you tackle this in the Java extension? We can also increase the timeout if needed?
My change for the terminate is still valid I believe.

sure, i'm fixing it in Java extension. Currently 500ms seems enough for us, let's keep it first. Will ping back if we need a longer timeout in future. thanks.

Sounds good, thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ryan-wong picture ryan-wong  路  3Comments

lukehoban picture lukehoban  路  3Comments

trstringer picture trstringer  路  3Comments

sirius1024 picture sirius1024  路  3Comments

shanalikhan picture shanalikhan  路  3Comments