-
Notifications
You must be signed in to change notification settings - Fork 31
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
Debug not working #71
Comments
Thanks for the detailed description. Unfortunately I couldn't reproduce this. Some suggestions:
That's all I can think of, after all it used to work and this extension hasn't changed for a while... |
Hello, @hbenl |
So the interesting thing is, I downloaded that version of VS Code that was linked and tried it and it worked. Then I quit and tried my existing one and it also started working. I don't know enough about VS Code to know if there is something that happens on starting up a different version that would fix this... I thought there might have been some setting that I reset that fixed it but didn't fix until after a restart, but I can't think of any. My settings are completely clear of any custom settings, and all setting in the Settings dialog are reset to defaults. |
After the previous comment it again stopped working similarly to the first time. I think the first time it failed it was with this error message:
Then, on subsequent runs it switches to the debug window and then does nothing with these logs:
Restarting VS Code twice got it working again. I will continue to investigate. @Cuprumbur does the problem go away for you upon restarting VS Code? |
@Cuprumbur thanks a lot for the repo, unfortunately I was not able to reproduce this. I've tried debugging the test dozens of times (on Linux and on Windows version 10.0.18362) and it didn't fail a single time. @meelash VS Code also has some "hidden" settings, where it stores parts of the editor state (e.g. source files that you have opened, breakpoints you have set, etc.) so that it can restore that state when it is restarted. But I don't think it's related to those either. I think this is most likely a problem in the latest version of VS Code. When this happens again, please open the VS Code developer tools (Menu item "Help" -> "Toggle Developer Tools" or Ctrl+Shift+I), go to the Console and look for error messages from VS Code appearing while you're trying to debug. |
@meelash Unfortunately, the problem still exists |
@hbenl I attached some info. |
@hbenl I have a slow computer. |
@Cuprumbur Thanks! |
@hbenl It still doesn't work properly. |
@meelash What about you, does version 2.1.3 work better for you? |
@hbenl I'm on 2.1.3, but still getting:
Of note is that this error only throws in the Mocha Explorer Log the first time. After that, it fails silently which is why I didn't initially know what the error was. |
Ah, I see that you did increase the timeout to 10 seconds, just forgot to update the error message. Increasing it to 20 seconds myself to see what happens. Again I have to restart 2 times for some reason for it to reset and start working again... |
VS Code 1.40.2 came out and it fixes this bug, which is probably the cause of this issue: users of other extensions complained about debugging javascript not working and it turns out that sometimes VS Code 1.40 will occupy port 9229, which is the default debugging port for node.js. Quote:
This would also explain why it happened on a slower computer but not a faster one: only on a slow computer VS Code would think that the extension host process is unresponsive and hence occupy port 9229. @Cuprumbur @meelash please tell me if it works for you with VS Code 1.40.2. I will also have a look at why there was no useful error message in the logs and try to fix that. |
In my experiments, the "Mocha Tests" output channel did contain an error message "Starting inspector on [...] failed: address already in use" and I couldn't find an easy way to improve on that. |
@hbenl Apologies for the delay, as I wanted to confirm my observations before replying. I can confirm the original issue was fixed by the VS Code update. I find two scenarios in which the debugger fails- One is if either my test or code did not clean up all in-use handles on a previous test (for example, ftp or database connection is left open) and multiple test processes are open. There is an issue in the mocha project about the test runner not forcibly killing the process when complete; personally, I think that is the correct behavior as it forces you to fix whatever the problem is. However, it might cause some confusion on the part of a new user why the debugger is not starting. Secondly, if there is an error in before/after/setup/teardown steps, the error is logged in Mocha Explorer Log (Output tab) but not in the Test Explorer log. The "Show Log" code visor also does not display. Maybe this is by design, that actual test failures show in the Test Explorer and failures of the test itself show in the Mocha Explorer Log? In summary, thanks for your time looking into the original issue, and to whoever fixed it on the VS Code side :) |
@meelash Thanks for the feedback!
You could try Mocha's
Yes, this is by design: the Test Explorer log is used to show the messages from a single test, but the messages from the before/after/setup/teardown steps can't be linked to any test, so they only show up in the "Mocha Tests" output channel (which I introduced specifically to make sure that there is a place where you can find all messages, including those that can't be linked to any test) |
TL;DR This worked for me. This tool was working great for me (awesome tool btw, thank you) and then it stopped debugging, wouldn't hit breakpoints any more. I noticed that the debug "remote process" kept running after the tests completed, so I tried the disconnect button, but that didn't help. Checked the log and saw stuff about port is already in use, so incremented the port- and it worked for one debug, but not for any debug attempts after that. For whatever reason (something I changed I assume), something caused the testing process to stop exiting when it finished. Killing the processes from the command line worked, but a hassle. Using the mochaExplorer.exit setting did the job. Debug is working smoothly again! |
I would recommend including before/after/setup/teardown steps in the test explorer log if it's possible, it's confusing to have them in separate places. Having the extension match the behavior of mocha on the terminal makes it more consistent with what the user expects. Thanks for making sure the before/... logs still show up somewhere, though. |
I had been using debugging of individual tests successfully (and gotten addicted to the feature :)) Suddenly, it stopped working. I thought it might be something in my project so to debug debug, I created a new workspace, only installed mocha, reset all settings to defaults, and just have a single test in test/index.js:
Running the individual test from the explorer or code lens works. Running from the mocha cli works. Running from the VS Code debugger works.
However when I click on Debug in the test explorer or code lens, it opens the debugger panel, shows the little floating menu:
but doesn't apparently do anything. Doesn't stop at breakpoints, doesn't run the test, doesn't log to console.
In the Mocha debug log there are just these lines and no errors:
Any ideas what this could be? I feel I must have modified some setting somewhere that killed my beloved per-test debugging but can't figure out what it is.
Help!
The text was updated successfully, but these errors were encountered: