vscode-nodejs-repl icon indicating copy to clipboard operation
vscode-nodejs-repl copied to clipboard

Infinite loop crashes plugin

Open omartan opened this issue 6 years ago • 5 comments

There must be a way to force exit the plugin in an event where an infinite loop crashes the plugin without having to close the window.

omartan avatar Apr 28 '18 01:04 omartan

yes, I will try to take a look into this. I may have to use a timeout or code-analysis for an infinite loop to catch this.

Behind the scenes, nodejs repl is used, and infinite loops is a problem here as well.

lostfields avatar Apr 28 '18 10:04 lostfields

Thanks, +1 for this issue. Thank you very much for your extension. It is really nice.

I think that trying to analyse if the program will have an infinite loop is an NP problem.. ;) (https://en.wikipedia.org/wiki/Halting_problem)

dchicurel avatar Mar 20 '19 18:03 dchicurel

I imagine you could establish a timeout like 60 seconds. If the script hasn't completed in that time, assume it's an infinite loop and terminate it. Then, put that number into the extension settings, so folks can change it if 60 seconds is not adequate.

tomprogers avatar May 27 '19 01:05 tomprogers

Could try to detect a large number of items in the call stack, calling of similar code in quick succession - however you detect, it's worth putting a notification saying something like "infinite loop detected" with actions to 'continue' or 'break'

EDIT: There might be a way to set an event listener for whether the allocated memory has been overdrawn by the running context, see https://devdocs.io/node/v8

LoveSponge avatar May 02 '20 03:05 LoveSponge

@lostfields is there anyway we can help you to do this? it's pretty essential for playing around with loops, algorithms etc (which is I guess one of the main reasons people use node repl)

btw thank you so much for building this!

gkatsanos avatar Feb 20 '22 07:02 gkatsanos