Closed ruslan-bikkinin closed 6 years ago
In the other issue I asked for a log file, are you able to provide a log file? In node and chrome-debug this is enabled when "trace": true
is set in the launch config, you can probably pass this in from your extension.
Hi @roblourens and sorry for such delayed response. I tried to do what you suggested to me, but, unfortunately, I couldn't gather any logs for some reason. Actually, I used this trick to pass trace
argument to debug adapter but with no success:
// We are extending ChromeDebugAdapter class to inject hack for "set breakpoint" issue.
// I am using it as well to force internal logging for debug adapter.
export function makeAdapter(debugAdapterClass: typeof ChromeDebugAdapter): typeof ChromeDebugAdapter {
return class extends debugAdapterClass {
protected doAttach(port: number, targetUrl?: string, address?: string, timeout?: number): Promise<void | DebugProtocol.Capabilities> {
// This is the hack we used to fix "set breakpoint" issue
// We need to overwrite ChromeDebug's _attachMode to let Node2 adapter
// to set up breakpoints on initial pause event
(this as any)._attachMode = false;
return super.doAttach(port, targetUrl, address, timeout);
}
// Override .attach() to pass trace and logFilePath arguments.
attach(args: IAttachRequestArgs): Promise<DebugProtocol.Capabilities | void>{
// I tried this...
//args.trace = "verbose";
//args.logFilePath = "/home/rbikkinin/nodedebug.log";
// ...and this..
args.trace = true;
// ...with no success
return super.attach(args);
}
};
}
I even debugged extension to make sure all additional args had been passed inside debug adapter, too. What am I doing wrong? Please let me know if you have any clues.
It should write the log file path to the debug console. It's not doing that? attach
should call commonArgs
, which calls logger.setup
.
@roblourens No, that's the point.
attach should call commonArgs, which calls logger.setup.
Yes, I saw this when I was debugging the debugger of extension, but for some reason it didn't help.
Can you step into setup to figure out what goes wrong after that?
@roblourens I'll try.
I think I'm experiencing the same behavior.
Launch config
{ "type": "node", "request": "launch", "name": "Jest Debug", "program": "${workspaceRoot}/node_modules/jest/bin/jest", "args": ["--runInBand"], "internalConsoleOptions": "neverOpen", "console": "integratedTerminal", "trace": true }
I have attached 2 trace files.
breakpoint-not-hit.txt: trace with breakpoint set before launching Jest Debug which never gets hit.
breakpoint-hit-after-start-debug-and-resetting.txt: trace where I launch Jest Debug and then spam adding and removing the breakpoint in my test while jest is running. This breakpoint usually gets hit (seems like i have to add the breakpoint while the file being tested by jest is in context for it to get hit every time).
VSCode:
Version 1.21.1 Commit 79b44aa704ce542d8ca4a3cc44cfca566e7720f1 Date 2018-03-14T14:46:47.128Z Shell 1.7.9 Renderer 58.0.3029.110 Node 7.9.0 Architecture x64
Node v9.10.1
Let me know if this helps.
That's not related to this issue. Please try in Insiders since I fixed a similar issue. Open a new issue if it happens in Insiders. https://code.visualstudio.com/insiders
Thanks for the response. Having the same issue with Insider. Will post issue there.
Version 1.22.0-insider Commit 6c22e21cdcd6811770ddcc0d8ac3174aaad03678 Date 2018-03-30T05:16:39.261Z Shell 1.7.12 Renderer 58.0.3029.110 Node 7.9.0 Architecture x64
Hi @roblourens and sorry for long delay. As I understand, logger hasn't _currentLogger
instance and that's why it isn't write logs to file (please take a look at screenshot below):
I tried to force logger to be initialized by calling init()
method but that didn't help.
import { logger } from "vscode-chrome-debug-core";
// ...
attach(args: IAttachRequestArgs): Promise<DebugProtocol.Capabilities | void> {
args.trace = "verbose";
args.logFilePath = "/home/rbikkinin/node-debug/log.log";
//force logger to initialize
logger.init((event: LogOutputEvent) => {
//just for testing
console.log(event);
}, "/home/rbikkinin/node-debug/log.log", true);
return super.attach(args);
}
The problem is that you load the node debug extension, but then also have your own separate copy of vscode-chrome-debug-core. The logger instance is stored as static state within the module, so in this case you have two separate instances.
I think it will work if you import the logger from node2's copy of vscode-chrome-debug-core and use that one instead.
using VSCode version 1.21.0. Breakpoints still not working. It's really frustrating that still this is not resolved.
Or if there workaround for this?
Hi @roblourens
I installed vscode-node-debug2
locally, forced nodeDebugAdapter
to write logs to file:
public initialize(args: DebugProtocol.InitializeRequestArguments): DebugProtocol.Capabilities {
this._adapterID = args.adapterID;
this._promiseRejectExceptionFilterEnabled = this.isExtensionHost();
this._supportsRunInTerminalRequest = args.supportsRunInTerminalRequest;
if (args.locale) {
localize = nls.config({ locale: args.locale })();
}
const capabilities = super.initialize(args);
capabilities.supportsLogPoints = true;
logger.init((event) => {}, "/home/rbikkinin/node-debug/log.log", true);
return capabilities;
}
and that's what I got in there:
Hope it helps to identify the cause of issue. If not, please let me know what else should I do.
JFYI: rn606
- this is React Native project which I was trying to debug.
It looks like it's missing logs, for some reason it doesn't include the 'setBreakpoint' request from the client. And I'm not sure what's going on where one of the first lines is Terminated: websocket closed
. Do you know why that is?
But I see it try to set the bp in app.js, then app.js is loaded and it loads the sourcemap correctly, but for some reason it doesn't resolve the bp with that sourcemap.
@roblourens after further investigation I found out that ChromeDebugAdapter instance calls validateBreakpointsPath
before sourcemaps will have loaded. It's very odd, because after that they are finally loaded as you can see here (index.bundle
includes app.js
content):
Who actually triggers validateBreakpointsPath
and can I do it by myself? Can I use it as workaround or may be there exists more pleasant way to do that? BTW issue doesn't reproduce on 1.19 version of vscode, so may be something changed in 1.20 that leads to such behavior?
The gif doesn't show anything wrong. The breakpoint is set, sourcemaps haven't loaded yet (this is expected). Then the sourcemap is loaded. What happens after that? I need a full log (yours seems to be missing some lines at least) or something I can debug.
Please schedule some time for us to have a call or something so we can work this out. After 2 weeks it takes a while for me to remember what I saw last time.
@roblourens got it, I'll mail you.
Hi everyone.
We are maintainers of
vscode-react-native
extension and recently we've got the following issue: https://github.com/Microsoft/vscode-react-native/issues/625#issuecomment-368421380 - for some reason, debugging does not stop on breakpoints on the first start, but it actually works as expected when we are removing and adding breakpoints again.As we know, previously the following hack has been implemented to avoid such kind of problem, but currently it does not work https://github.com/Microsoft/vscode-react-native/blob/e315e3db8545c6f69dd85e9bb0b17b239e52500b/src/debugger/nodeDebugWrapper.ts#L205.
This issue DOES NOT reproduce on previous versions of Vs code such as
1.19.3
or0.18.1
, but DOES reproduce on the latest one:1.20.1
.@roblourens here: https://github.com/Microsoft/vscode-chrome-debug-core/issues/293#issuecomment-371221015 supposes that something changed in
vscode-node-debug2
between those versions.We have a lot of users affected by this issue so we are hoping that somebody from
vscode-node-debug2
team could help us to understand what is the cause of problem. Any advices, clues will be much appreciated as well.