microsoft / vscode-debugadapter-node

Debug adapter protocol and implementation for VS Code.
Other
271 stars 77 forks source link

testsupport: allow disabling timeouts with stdio connection #286

Open justarandomgeek opened 1 year ago

justarandomgeek commented 1 year ago

I've been struggling significantly with getting the testsupport client to run my debugadapter, and in the process have needed to attach a debugger to my debug adapter running under the testsupport client, but it does not run in network mode, so I keep getting cut off by the timeouts from testsupport, and i can't seem to disable them. Additionally, when I set the timeout to a very long time (several minutes), it hangs the process for that long after debugging ends, even if nothing else is going on.

roblourens commented 1 year ago

Sorry, which timeouts from testsupport? And it's not clear why that is hanging the process. It has been a bit since I looked at this code, apologies, but I want the dev experience to be good.

justarandomgeek commented 1 year ago

The ones that it says it disables when using a tcp port in .start()?

I've once again done a horrible hack for now, but... seriously? having to do silly stuff like this is nuts!

await dc.start();
// fake "socket" to disable timeouts
(dc as any)._socket = { end: ()=>{} };
justarandomgeek commented 1 year ago

Further investigation has revealed that these timeouts were merely a red herring for my actual issue (stdin pipes breaking due to testrunner console weirdness), but an option to disable them for testing still seems worthwhile.

justarandomgeek commented 1 year ago

The hang occurs becuase:

  1. A test runs to a point where the debugee exits
  2. The adapter emits a Terminated event, and itself exits (gracefully, so that i can get coverage info from tests too - if i wait for .stop to kill it i get none because on windows a kill is really a kill)
  3. The test suite calls DebugClient.stop() (because the example showed that, and because some tests might not run to termination)
  4. The DebugClient sends a disconnect request to the dead adapter, and waits for the long timeout

https://github.com/microsoft/vscode-debugadapter-node/blob/a533ebce7c9e159f778c11147a5c3eb7e1ba11d3/testSupport/src/debugClient.ts#L124