slowpoke
v1.0.0
Published
Detect slow-running loops and abort after a user-defined timeout
Downloads
13
Maintainers
Readme
slowpoke
slowpoke
takes as input an AST generated by esprima
and injects instrumentation code into all for
, while
and do
loops encountered therein. Any loop which does not terminate after a user-specified timeout will throw an error.
Installation
Get it:
$ npm install slowpoke
Require it:
var slowpoke = require('slowpoke');
API
slowpoke(ast, options)
Modifies ast
in-place such that all slow loops will throw an Error
. ast
must be an esprima
-compatible AST structure.
Supported options
:
timeout
: number of milliseconds after which loop should abort. Default:5000
.
Limitations
slowpoke
only catches slow for
, while
and do
loops - it cannot detect unbounded recursion.
Because slowpoke
uses Error
throwing as its abort mechanism, code containing try
/catch
may not function as intended. Future work could modify catch
blocks re-raise errors thrown by slow loops.