Vscode: Implement a watch-dog mechanism which can kill runaway extension host processes

Created on 11 May 2017  路  9Comments  路  Source: microsoft/vscode

In certain circumstances, e.g. extension that does while (true) loop, the extension host process will not terminate unless killed via task manager.

Implement a watch-dog mechanism that can kill runaway extension host processes.

NB: This was not an issue on Windows until we made the process be forked with the detached option to allow 5s for the extensions to gracefully shut down.

extensions on-testplan plan-item

Most helpful comment

Can this also detect how much % CPU the process is using, give a notification which process is long-running, and give the user the option of restarting/killing it? That way you would also expose potentially problematic extensions?

All 9 comments

An idea would be to:

  • write a nodejs native addon
  • it installs an interval timer on the JS event loop
  • at each execution of the timer, a call is made to C++ land to let it know the JS event loop is alive
  • create a thread that sleeps for ~20s in a cycle
  • when the thread wakes up, it checks the last time the JS event loop was alive

API: http://docs.libuv.org/en/v1.x/threading.html

Cool idea. Will avoid having yet another process running.

Can this also detect how much % CPU the process is using, give a notification which process is long-running, and give the user the option of restarting/killing it? That way you would also expose potentially problematic extensions?

Well, we'd want the JS stack trace, not the C++ one (otherwise we'd just see v8 being in the stack).

That appears to be difficult from the discussion in https://github.com/nodejs/node-v0.x-archive/issues/25263

Due to instability (increased number of crashes), the watch-dog code is now disabled -- starting with today's Insiders Build (2017-08-23). We have also upgraded to Electron 1.7.4 and 1.7.5 and we should be cautious of introducing too much instability at once (see also #33016).

Re-iterating thoughts expressed by @sjelfull . I've been suffering from high cpu on an rMBP and can't figure out which extension is causing this.

This is overly tough to diagnose: whenever I launch developer tools, it seems the problem goes away...literally, I launch the tools and the fans start to calm down, eventually turning off completely. Makes no sense. Because I have no idea what's causing it, I can't try to repro. The problem just seems to randomly appear.

Having some sort of automated way to identify problematic extensions would be extremely helpful, perhaps more so than just quietly killing them.

This has been implemented now on master.

Adding verification needed, but this probably needs some test plan input and testing across OS (cc @mjbvz).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

curtw picture curtw  路  3Comments

omidgolparvar picture omidgolparvar  路  3Comments

sijad picture sijad  路  3Comments

vsccarl picture vsccarl  路  3Comments

shanalikhan picture shanalikhan  路  3Comments