Skip to content
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

When a debug adapter crashes, the exception text is not propagated to the console #41190

Closed
DanTup opened this issue Jan 5, 2018 · 15 comments · Fixed by #56917
Closed

When a debug adapter crashes, the exception text is not propagated to the console #41190

DanTup opened this issue Jan 5, 2018 · 15 comments · Fixed by #56917
Assignees
Labels
debt Code quality issues debug Debug viewlet, configurations, breakpoints, adapter issues
Milestone

Comments

@DanTup
Copy link
Contributor

DanTup commented Jan 5, 2018

I've had a couple of people report debug adapter crashes recently. One of them I'm unable to reproduce which means I need to get more information from the user. Currently, when a debug adapter crashes, the error information that appears in the console is very vague:

debug adapter crash

The actual exception that was thrown is not shown. Since I can't repro this, the only ways I can think of to debug are:

  1. Add try/catch around all debugger methods that handles errors and passes them back nicely (and remember to do this for all future methods)
  2. Get the user to run my project from source and debug the debug adapter to catch the error (whilst not the hardest thing in the world, it's a bit involved for an end user)

Is it possible to get better information from the error back into the console without having a debugger attached to debug adapter?

@vscodebot vscodebot bot added the debug Debug viewlet, configurations, breakpoints, adapter issues label Jan 5, 2018
@DanTup
Copy link
Contributor Author

DanTup commented Jan 5, 2018

I don't know if the text "ERR" in the console was actually supposed to be my error; but it isn't. My error was "AAAAAARGH".

@isidorn
Copy link
Contributor

isidorn commented Jan 5, 2018

@DanTup this request makes sense.
Not sure though if I am getting your error when your process crashes. Can you be so kind and set a breakpoint here make your server crash and check if your message is coming through as a signal or as something else.

Thanks

@isidorn isidorn added the info-needed Issue requires more information from poster label Jan 5, 2018
@DanTup
Copy link
Contributor Author

DanTup commented Jan 5, 2018

@isidorn Do you mean the ERR text? I also don't get that now when trying to repro, only the "terminated unexpectedly" message.

If you still want me to try that breakpoint, can you explain how to add a breakpoint there. I did try breaking in my adapter and navigating the callstack (that file wasn't in there anywhere) and also checking the filenames of the files that were (they showed <node internals>).

@isidorn
Copy link
Contributor

isidorn commented Jan 5, 2018

@DanTup I mean let's try to see if your error "AAAAARGH" surfaces on our side.
You should be able to just run regular vscode, F1 > open developer tools, wait some time and put a breakpoint by openning a rawDebugSession.ts.
Also try to put a breakpoint here and check if the error stream spits up something.

@isidorn isidorn added this to the December 2017/January 2018 milestone Jan 5, 2018
@ncannasse
Copy link

The breakpoint is not hit, which is perfectly normal since the exception occurs before the socket connection is created. You should be able to reproduce by adding require('unknown_module') to the top of any debugger extension .js file

@DanTup
Copy link
Contributor Author

DanTup commented Jan 5, 2018

Ok, I got breakpoints in both onServerError and onServerExit. First wasn't called and the second was called but code is 1 and signal is null. So seems like the message isn't there.

For testing, all I've done is put throw "AAAAARGH"; inside my debug adapter.

Though now I think about it; the error isn't occurring in code that's been executed directly by Code - it's during the response from my debugger. In my debug adapter I spawn a process and I add a handler for stdout. When something comes over stdout and my callback runs, that's where the crash is occurring. I don't know if this changes things (for example, I don't know if this is on another thread?).

@DanTup
Copy link
Contributor Author

DanTup commented Jan 5, 2018

Also try to put a breakpoint here and check if the error stream spits up something.

That one (in connectServer) didn't seem to be hit either.

@DanTup
Copy link
Contributor Author

DanTup commented Jan 5, 2018

Actually, I think I can repro this really easily by just putting throw "test"; in the constructor of the DebugSession? Also gets code=1, signal=null.

export class DartDebugSession extends DebugSession {
	public constructor() {
		super();
		throw "test";
	}

@isidorn isidorn modified the milestones: January 2018, February 2018 Jan 31, 2018
@isidorn isidorn modified the milestones: February 2018, March 2018 Mar 1, 2018
@DanTup
Copy link
Contributor Author

DanTup commented Mar 4, 2018

@isidorn This issue has the needs-more-info tag though I think it's easily reproducible with my last comment. Let me know if that's not the case!

@isidorn isidorn removed the info-needed Issue requires more information from poster label Mar 5, 2018
@isidorn
Copy link
Contributor

isidorn commented Mar 5, 2018

@DanTup I have removed tha tag and plan to look into this issue this week. Thanks

@isidorn
Copy link
Contributor

isidorn commented Mar 16, 2018

Investigated and the issue here is that I am not getting any exception data from the spawned process.
I simply get the exit code here while all the other error chanels are blank. I am not sure what would be the proper solution here.
Suggestions are very welcome. Also @weinand @bpasero

@DanTup @ncannasse are all your debug adapters launched using node? If yes then it might be that our stdFork launch is somehow eating up the error if it happens on startup.
If this also happens for adapters which are not realying on node to be launched then stdFork is not to blame.

@weinand
Copy link
Contributor

weinand commented Mar 16, 2018

@isidorn please try to disable the stdfork launch for node (here) and see whether this makes a difference. DAs should work independent from stdfork. But make sure that the node version used is roughly the same as Electron's version (i.e. 7.9.0).

@isidorn
Copy link
Contributor

isidorn commented Mar 16, 2018

Yes, using stdfork is the cause here. If I do not use it, I nicely get the error popping up in the extensions output channel.

My weekend is starting if someone is feeling smart code review this file and let me know if you find something fishy about stderr not being wired through.

@weinand
Copy link
Contributor

weinand commented Mar 16, 2018

Then you might want to involve/assign @alexandrudima.

@isidorn
Copy link
Contributor

isidorn commented Mar 27, 2018

I am going on a vacation tomorrow evening, and this is like this since forever so pushing to April to investigate with Alex what is going on behind the curatans here.

@isidorn isidorn modified the milestones: March 2018, April 2018 Mar 27, 2018
@isidorn isidorn modified the milestones: April 2018, May 2018 Apr 25, 2018
@isidorn isidorn modified the milestones: May 2018, June 2018 May 30, 2018
@isidorn isidorn modified the milestones: June 2018, July 2018 Jun 28, 2018
@isidorn isidorn modified the milestones: July 2018, August 2018 Jul 27, 2018
isidorn added a commit that referenced this issue Aug 21, 2018
@isidorn isidorn added the debt Code quality issues label Aug 22, 2018
@vscodebot vscodebot bot locked and limited conversation to collaborators Oct 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
debt Code quality issues debug Debug viewlet, configurations, breakpoints, adapter issues
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants